Deirdre Connolly
13b6ff1c65
Add 32byte and 64 bytes convenience writer methods to WriteExt
2020-08-14 02:04:12 -04:00
Deirdre Connolly
e8fdd0e1f3
Impl TryFrom for Commitments, call from impl ZcashDeserialize
2020-08-14 02:04:12 -04:00
Deirdre Connolly
5d13880461
Remove Zcash(De)Serialize impls for *Commitments
2020-08-14 02:04:12 -04:00
Deirdre Connolly
014afd8e4a
Move Pedersen hash functions to their own submodule
2020-08-14 02:04:12 -04:00
Deirdre Connolly
be7ea200c8
Accept an Amount<NonNegative> for the value arg of a ValueCommitment constructor
2020-08-14 02:04:12 -04:00
Deirdre Connolly
e024e43896
Support nullifier derivation from borrowed Spending, NullifierDeriving keys
2020-08-14 02:04:12 -04:00
Deirdre Connolly
40b5a73a15
impl From<&NullifierDerivingKey>, use that to derive Sapling Nullifier
2020-08-14 02:04:12 -04:00
Deirdre Connolly
a8625b7b84
Remove empty doc comment
2020-08-14 02:04:12 -04:00
Deirdre Connolly
a3530b0eed
Move pedersen_hash() to go with the other Sapling hash functions, for now
2020-08-14 02:04:12 -04:00
Deirdre Connolly
0242df30cb
A space
2020-08-14 02:04:12 -04:00
Deirdre Connolly
9d9491c4e8
Index at 1, not 0, the main loop of PedersenHashToPoint, to match spec math
2020-08-14 02:04:12 -04:00
Deirdre Connolly
e5c07721b4
Typo fix
...
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly
ca81e48843
Remove an extra line
2020-08-14 02:04:12 -04:00
Deirdre Connolly
60ae9d74e7
Typo
...
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly
fe45c6402a
Remove clippy::unit_arg allowance
2020-08-14 02:04:12 -04:00
Deirdre Connolly
2942bad6ff
Make diversify_hash() private again
2020-08-14 02:04:12 -04:00
Deirdre Connolly
5a249f8da5
A space
...
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-08-14 02:04:12 -04:00
Deirdre Connolly
5ba453c2a1
Remove unused SaplingNoteTreeRootHash types re: Heartwood
2020-08-14 02:04:12 -04:00
Deirdre Connolly
68871c5bd4
From<Nullifier> for [u8; 32]
2020-08-14 02:04:12 -04:00
Deirdre Connolly
b2584c4a8f
A space
2020-08-14 02:04:12 -04:00
Deirdre Connolly
0c299972ec
Clarify docstring about the Jubjub prime-order subgroup on generate_trapdoor()
2020-08-14 02:04:12 -04:00
Deirdre Connolly
f816761a5c
The pedersen hash to point test vectors now pass
2020-08-14 02:04:12 -04:00
Deirdre Connolly
425275ad35
Fix exclusive range, shift up enumerate() indexes with map()
2020-08-14 02:04:12 -04:00
Deirdre Connolly
be22ef64e5
At least fewer M_i() rounds for test cases
2020-08-14 02:04:12 -04:00
Deirdre Connolly
41c8076dab
Add test vectors that aren't being consumed right now
2020-08-14 02:04:12 -04:00
Deirdre Connolly
14d502a54b
Compute pedersen hash to point in scalar field
2020-08-14 02:04:12 -04:00
Deirdre Connolly
8ececebea7
A space
...
Co-authored-by: teor <teor@riseup.net>
2020-08-14 02:04:12 -04:00
Deirdre Connolly
3b01dc50ef
Use unicode scalar field characters instead of LaTeX
...
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2020-08-14 02:04:12 -04:00
Deirdre Connolly
1d494a2b7a
Docstring wrap
2020-08-14 02:04:12 -04:00
Deirdre Connolly
e22afa3c8f
Generate uniformly random scalar w/ Fr::from_bytes_wide()
...
Which reduces mod r always.
2020-08-14 02:04:12 -04:00
Deirdre Connolly
c46cda920f
Add primitive merkle_crh_sapling function
2020-08-14 02:04:12 -04:00
Deirdre Connolly
10a9aa5844
Add prf_nf and use in From impl to derive Sapling Nullifier
2020-08-14 02:04:12 -04:00
Deirdre Connolly
eb731a6e2f
Add note commitment tree Position type
2020-08-14 02:04:12 -04:00
Deirdre Connolly
65f8f2c613
Add mixing_pedersen_hash
...
Tidy constructors for NoteCommitment
2020-08-14 02:04:12 -04:00
Deirdre Connolly
ed888b38ef
Correctly generate a sapling NoteCommitment from the NoteCommitmentRandomness
2020-08-14 02:04:12 -04:00
Deirdre Connolly
b6385ca36f
Move commitment types into commitments module
...
Docs, tidy
2020-08-14 02:04:12 -04:00
Deirdre Connolly
4ccec84768
Add explicit pedersen_hash function
2020-08-14 02:04:12 -04:00
Deirdre Connolly
83c41869e1
Improve docs
2020-08-14 02:04:12 -04:00
Deirdre Connolly
caef323f9b
pedersen_hash_to_point() works, with submethods using bitvec
...
Also tidy, document
2020-08-14 02:04:12 -04:00
Deirdre Connolly
919557c20c
My BitSlice doesn't have a known size at compile time?
...
error[E0277]: the size for values of type cannot be known at compilation time
2020-08-14 02:04:12 -04:00
Deirdre Connolly
579f1ed134
Flesh out windowed_pedersen_commitment_r
2020-08-14 02:04:12 -04:00
Deirdre Connolly
9d87f30d18
Start of, but currently unfinished, Sapling note commitment / Windowed Pedersen Commitment
2020-08-14 02:04:12 -04:00
Deirdre Connolly
f64e0c4bc5
Sapling value commitment, half done Sapling note commitment
2020-08-14 02:04:12 -04:00
Deirdre Connolly
823b06b219
Break out subtypes into modules, including arbitrary's
2020-08-14 02:04:12 -04:00
Deirdre Connolly
dfb10ab10f
Add NoteCommitment.extract_u()
2020-08-14 02:04:12 -04:00
Deirdre Connolly
33730a05cb
Do not confuse a NoteCommitment for U(NoteCommitment)
2020-08-14 02:04:12 -04:00
Deirdre Connolly
0f46a9b6a8
NoteCommitments, renames, ValueCommitment, strategies, stub commit()
2020-08-14 02:04:12 -04:00
Deirdre Connolly
fa053e2b0b
Derive a Sprout nullifier from a nullifier seed (rho) and spending key
2020-08-14 02:04:12 -04:00
Deirdre Connolly
0d618a3abf
Start treestate module
2020-08-14 02:04:12 -04:00
Deirdre Connolly
28a7420079
Remove unused imports
2020-08-14 02:04:12 -04:00
Deirdre Connolly
15899bc6d3
More Note refinements
2020-08-14 02:04:12 -04:00
Deirdre Connolly
2c285985c8
Move nullifiers to respective note modules, pull in existing types from keys
2020-08-14 02:04:12 -04:00
Jane Lusby
8b78a55c71
Start work implementing sprout note commitment function
2020-08-14 02:04:12 -04:00
teor
0e21a70b88
feature: Implement CompactDifficulty to Work ( #838 )
...
* Implement CompactDifficulty to Work
* Add Bitcoin test vectors for difficulty
2020-08-14 09:48:15 +10:00
Henry de Valence
07917421cb
Correct coinbase check ( #898 )
...
* chain: add Transaction::is_coinbase()
This matches the check in zcashd/src/primitives/transaction.h:682
(CTransaction::IsCoinBase).
* chain: correct Block::is_coinbase_first
This matches zcashd/src/main.cpp:3968-3974 in CheckBlock.
Previously, the check allowed the first transaction to have multiple coinbase inputs.
* chain: return slices from Transaction::inputs()/outputs()
They're slices internally so we might as well just expose them that way.
2020-08-13 14:04:43 -07:00
Henry de Valence
36093b4721
Tweak light client root hash definition.
...
This changes the `light_client_root_hash` field to `light_client_root_bytes` to
hint that it's unparsed, and makes it public to match the rest of the
`BlockHeader` fields. The `LightClientRootHash` serialization methods are
hidden from the public API, so that the `LightClientRootHash` has to be
constructed by the method on the `Block`.
2020-08-11 19:13:50 -04:00
dependabot[bot]
5cb61136c9
build(deps): bump tracing from 0.1.18 to 0.1.19 ( #872 )
...
Bumps [tracing](https://github.com/tokio-rs/tracing ) from 0.1.18 to 0.1.19.
- [Release notes](https://github.com/tokio-rs/tracing/releases )
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.18...tracing-0.1.19 )
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-08-11 10:18:54 -07:00
Henry de Valence
f8a24f9c11
Rename script fields to lock/unlock scripts. ( #866 )
...
This is slightly clearer and more correct than the previous pk_script.
2020-08-10 11:49:38 -07:00
teor
7afd76f5fb
feature: Add light_client_root_hash(network) to Block
...
* use the right variant in LightClientRootHash::from_bytes()
* make block.header.light_client_root_hash pub(super)
* add tests for LightClientRootHash and block.light_client_root_hash
2020-08-10 18:54:42 +10:00
teor
ee6f0de14d
refactor: Move NetworkUpgrade to zebra-chain
2020-08-10 18:54:42 +10:00
teor
c4eb136426
feature: Add a LightClientRootHash type
2020-08-10 18:54:42 +10:00
teor
53ce01fd23
fix: Rename the light client hash field
2020-08-10 18:54:42 +10:00
Henry de Valence
a987394782
Add KaTeX to rendered docs. ( #832 )
...
This adds a single test formula to the `zebra-chain` docs. We can remove it
after merging this and running it through CI to confirm that it works.
2020-08-05 17:34:30 -07:00
teor
d49c11ee70
fix: Allow PROPTEST_CASES to override the lower block case default
2020-08-05 02:07:05 -07:00
teor
ac7a4ae517
fix: Speed up the block round trip proptest
...
Reduce the number of cases run by the block round trip proptest, to
speed up the Zebra tests.
2020-08-04 22:35:01 -07:00
teor
78b5bf5e9a
refactor: Move the difficulty tests into their own file
2020-08-04 15:24:52 -04:00
teor
efb9313460
fix: Resolve a type ambiguity in a proptest
...
For some reason, implementing
`PartialOrd<BlockHeaderHash> for ExpandedDifficulty` (or its converse)
makes this unrelated code ambiguous.
2020-08-04 12:29:07 +10:00
teor
c8b502a5da
feature: Compare ExpandedDifficulty and BlockHeaderHash
2020-08-04 12:29:07 +10:00
teor
b7fac7b3bc
feature: Make ExpandedDifficulty use U256 internally
...
Adds a dependency on the primitive-types crate.
Also adds custom hex debug formatting for compact and expanded
difficulties.
2020-08-04 12:29:07 +10:00
teor
c04d1b7b8f
doc: Consensus-critical difficulty encodings
2020-08-04 12:29:07 +10:00
teor
06157a7c8e
Update the BlockHeader fields for Heartwood ( #767 )
...
The Heartwood upgrade changes the meaning of the hashFinalSaplingRoot to
hashLightClientRoot. Since we don't know the network upgrade heights in
zebra-chain, we just use [u8; 32] for now.
2020-08-04 12:15:28 +10:00
dependabot[bot]
f3b65f9609
build(deps): bump tracing from 0.1.17 to 0.1.18
...
Bumps [tracing](https://github.com/tokio-rs/tracing ) from 0.1.17 to 0.1.18.
- [Release notes](https://github.com/tokio-rs/tracing/releases )
- [Commits](https://github.com/tokio-rs/tracing/compare/tracing-0.1.17...tracing-0.1.18 )
Signed-off-by: dependabot[bot] <support@github.com>
2020-08-03 15:49:30 -04:00
teor
195948e5b1
feature: Add an ExpandedDifficulty type and conversion
...
Also add tests.
2020-08-03 10:28:31 +10:00
teor
c4dec3fb36
feature: Make a CompactDifficulty wrapper
...
Wrap the compact difficulty "bits" field in a CompactDifficulty struct,
and rename the header field for clarity.
2020-08-03 10:28:31 +10:00
Jane Lusby
1015db25a8
remap the state storage to only store blocks once ( #741 )
2020-07-31 09:21:54 +10:00
Henry de Valence
7d0a3debb6
chain: ensure impl Deserialize for Amount validates data.
...
This uses serde's try_from attribute to run deserialized values through the
TryFrom impl. Also adds a test to make sure that validation actually does
happen.
2020-07-28 12:20:40 -07:00
teor
5ece62f0a5
fix: Update comments for Heartwood's hashChainHistoryRoot
2020-07-27 14:00:56 -04:00
Henry de Valence
4aa00ad216
Align crate versions and user-agent with NU numbers.
...
We had a brief discussion on discord and it seemed like we had consensus on the
following versioning policy:
* zebrad: match major version to NU version, so we will start by releasing
zebrad 3.0.0;
* zebra-* libraries: start by matching zebrad's version, then increment major
versions of each library as we need to make breaking changes (potentially
faster than the zebrad version, always respecting semver but making no
guarantees about the longevity of major releases).
This commit sets all of the crate versions to 3.0.0-alpha.0 -- the -alpha.0
marks it as a prerelease not subject to perfect adherence to compatibility
guarantees.
2020-07-24 11:46:37 -07:00
teor
41225660fb
doc: The genesis coinbase is the same in every network
2020-07-23 03:46:24 -04:00
Jane Lusby
7d4e717182
Add block locator request to state layer ( #712 )
...
* Add block locator request to state layer
* pass genesis in request
* Update zebrad/src/commands/start/sync.rs
* fix errors
2020-07-22 18:01:31 -07:00
Henry de Valence
90ec2982bf
docs: fix broken links
2020-07-22 17:55:52 -07:00
Alfredo Garcia
db2eb80b3e
Create consensus utils and move byte_reverse_hex function to it ( #705 )
...
* move byte_reverse_hex function
2020-07-22 12:29:14 +10:00
Jane Lusby
b8de256c48
remove serialization error variant of EquihashError
2020-07-22 11:09:22 +10:00
teor
1b0c0f027f
Add Hard-Coded Checkpoint Lists ( #674 )
...
* Add checkpoint list generation scripts
* Limit the checkpoint block data size
* Limit the checkpoint height gap
* Add Mainnet and Testnet checkpoint lists
* Parse hard-coded checkpoint lists
The lists were generated using the following limits:
- 256 MB spacing, based on block byte size, and
- 2000 blocks.
2020-07-21 23:11:51 +10:00
dependabot[bot]
474de52e5c
build(deps): bump displaydoc from 0.1.6 to 0.1.7 ( #689 )
...
Bumps [displaydoc](https://github.com/yaahc/displaydoc ) from 0.1.6 to 0.1.7.
- [Release notes](https://github.com/yaahc/displaydoc/releases )
- [Commits](https://github.com/yaahc/displaydoc/commits )
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-20 11:00:15 -07:00
Alfredo Garcia
fe2a468417
add favicon to generated docs ( #681 )
2020-07-17 16:45:29 -07:00
teor
1915634d2b
Check for bad heights or hashes in checkpoint lists ( #639 )
...
* Add MIN and MAX for BlockHeight and LockTime
* Remove duplicate test cases
* fix a comment about the minimum lock time
The minimum LockTime::Time is 5 November 1985 00:53:20 UTC, so the first
day that only contains valid times is 6 November 1985 (in all timezones).
Similarly, the maximum LockTime::Time is 7 February 2106 06::28::15 UTC,
so the last day that only contains valid times in all time zones is
5 February 2106.
* fix: Reject checkpoint lists with bad hashes or heights
Reject the all-zeroes hash, because it is the parent hash of the genesis
block, and should never appear in a checkpoint list.
Reject checkpoint heights that are greater than the maximum block
height.
2020-07-16 15:09:22 +10:00
teor
a19fdd9f25
fix: Rename to is_time_valid_at
2020-07-15 09:16:54 -07:00
teor
b2bb872df0
Use Unicode for section reference
...
Co-authored-by: Henry de Valence <hdevalence@hdevalence.ca>
2020-07-15 09:16:54 -07:00
teor
c2e4f7b0a5
refactor: Move the local clock check to a BlockHeader method
2020-07-15 09:16:54 -07:00
teor
5548dffd3b
refactor: Move the coinbase first check to a Block method
2020-07-15 09:16:54 -07:00
teor
e452ba1c13
fix: Use matches!() based on a new nightly clippy lint
2020-07-15 12:50:11 +10:00
Jane Lusby
06fff62561
remove git dependency on equihash crate
2020-07-10 07:52:52 -04:00
Alfredo Garcia
5d6a5ca329
Add consensus coinbase checks ( #593 )
...
* add coinbase check and test case
Co-authored-by: Jane Lusby <jane@zfnd.org>
2020-07-10 09:13:44 +10:00
Jane Lusby
0474a79669
Add cool helpers for using zcash_serialize / zcash_deserialize ( #586 )
...
Co-authored-by: Dimitris Apostolou <dimitris.apostolou@icloud.com>
2020-07-09 15:29:31 -04:00
Henry de Valence
8b72781fe1
deps: Update redjubjub to 0.2
...
Closes #606 .
2020-07-09 15:20:23 -04:00
Alfredo Garcia
f14e577ea9
apply clippy code suggestions
2020-07-07 18:33:14 -04:00
Henry de Valence
68f57b2577
Update ed25519-zebra to 1.0.
2020-07-07 11:49:21 -07:00
Henry de Valence
e54438f4e4
Update zebra-chain/src/block/header.rs
2020-07-07 11:13:49 -07:00
Dimitris Apostolou
ba81d7d4c0
Fix typos
2020-07-07 11:13:49 -07:00