Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Crypto Upgrades from #153 #197

Merged
merged 16 commits into from
Aug 23, 2022
Merged

Migrate Crypto Upgrades from #153 #197

merged 16 commits into from
Aug 23, 2022

Conversation

bhgomes
Copy link
Contributor

@bhgomes bhgomes commented Aug 9, 2022

Signed-off-by: Brandon H. Gomes bhgomes@pm.me

Changed Interfaces

  • manta_crypto::accumulator: Add Types base-trait for accumulator constructions. Now MembershipProof depends only on M: Types instead of M: Model<COM> so we can remove the compiler parameter and also add standard derive impls
  • manta_crypto::algebra: Rewrites the Group trait into the following set of traits Group, Ring, ScalarMul, ScalarMulGroup, and HasGenerator
  • manta_crypto::constraint: Replace ProofSystemInput with the Input/HasInput trait-pair (Input for implementation and HasInput for introspection)
  • manta_crypto::eclair::num: Expand Zero and One traits to match standard traits (including zero and one functions respectively)
  • manta_crypto::permutation::duplex: Add custom Plaintext and Ciphertext types to duplex encryption since Vec<PlaintextBlock> and Vec<CiphertextBlock> will not work (these are not fixed-size and cannot be allocated in the unknown case) we force the implementer to handle this instead of providing a half-solution. We also fix Poseidion encryption to handle this new correct allocation story

New Implementations or Removed Unused Code

Cryptography manta_crypto

  • accumulator: Remove unused ItemHashAccumulatorModel
  • accumulator: Remove unused are_independent from Accumulator
  • arkworks::ff: Add try_into_XXX integer conversion methods from F: PrimeField (with testing suite)
  • constraint::measure: Add Measure implementation for () the native compiler (currently no operations have a cost in this model, we can revisit this)
  • constraint::measure: Add print_measurement helper function to wrap any ECLAIR function call and print out it's measured size
  • eclair: Add Type introspection for the Has trait
  • eclair::alloc: Add Constant implementations for bool, [T; N], Vec<T>, Box<[T]>, Array<T, N>, and BoxArray<T, N>
  • eclair::alloc: Add Variable implementations for Box<T>, [T; N], Array<T>, BoxArray<T>
  • eclair::alloc: Generalize Allocate interface
  • eclair::bool: Implement Assert for ()
  • eclair::bool: Add ConditionalSelect implementations for native integer types
  • eclair::cmp: Add PartialEq implementations for native integer types and for Vec<T>, Box<[T]>, Array<T, N>, BoxArray<T, N>
  • eclair::num: Add Zero and One implementations for integer types, UnsignedInteger and arkworks backend variables
  • eclair::num: Add PartialEq, ConditionalSelect, ConditionalSwap and Variable implementations for UnsignedInteger
  • encryption: Add encryption::EmptyHeader type for encryption schemes with no headers
  • encryption: Add Encode and constraint::Input implementations to encryption::EncryptedMessage
  • encryption::hybrid: Add Variable implementation to hybrid::Randomness, hybrid::Ciphertext
  • encryption::hybrid: Add Encode and constraint::Input implementations to hybrid::Ciphertext
  • permutation::duplex: Add Variable, PartialEq, Encode, and constraint::Input implementations to duplex::Ciphertext
  • permutation::duplex: Add Constant and Sample implementations to duplex::Duplexer
  • rand: Add Sample implementations for PhantomData and ()
  • signature: Add more type aliases for signature schemes
  • signature::convert: Add signature message converters
  • signature::schnorr: Add HasGenerator implementation to Schnorr signature and simplify type bounds

Accounting manta_accounting

  • transfer: Removed the is_independent_from methods for Sender/Receiver (unused)

Utilities manta_util

  • bytes: Move AsBytes to manta_util
  • codec: Add more Encode implementations for native types
  • convert: Add Field and Variant introspection accessors
  • cmp: Add Independence relation which is a more general kind of non-equivalence relation. We will use it to distinguish between the kind of equivalence relation that checks if two nullifiers are strictly equal or their spend-receipt parts are equal (in the new protocol the Nullifier = (commitment, outgoing_note) and only the commitment is used to check the spend criterion so the independence relation checks if two commitments are unequal)
  • iter: Add Iterable extension traits for borrowed-iteration abstractions

Miscelanous Updates

  • Expanded CI contexts
  • Expanded NonNative trait docs
  • Upgraded clap, serde and anyhow
  • Downgraded bip32 (v0.4.0 is incompatible with some node dependenices)

Before we can merge this PR, please make sure that all the following items have been checked off:

  • Linked to an issue with discussion and accepted design OR have an explanation in the PR that describes this work.
  • Added one line describing your change in CHANGELOG.md and added the appropriate changelog label to the PR.
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Checked that changes and commits conform to the standards outlined in CONTRIBUTING.md.
  • Ran cargo hakari generate to update the workspace-hack system

Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
@bhgomes bhgomes self-assigned this Aug 9, 2022
@bhgomes bhgomes added changelog:added Changelog: add these changes to the `added` section of the changelog A-cryptography Area: Issues and PRs related to Cryptography labels Aug 9, 2022
@bhgomes bhgomes added this to the v0.5.5 milestone Aug 9, 2022
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
@bhgomes bhgomes marked this pull request as ready for review August 9, 2022 23:25
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
GhostOfGauss
GhostOfGauss previously approved these changes Aug 11, 2022
manta-crypto/src/eclair/mod.rs Show resolved Hide resolved
manta-crypto/src/algebra.rs Outdated Show resolved Hide resolved
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
manta-pay/src/crypto/ecc/arkworks.rs Show resolved Hide resolved
manta-pay/src/crypto/ecc/arkworks.rs Show resolved Hide resolved
manta-crypto/src/algebra.rs Outdated Show resolved Hide resolved
manta-crypto/src/algebra.rs Show resolved Hide resolved
manta-crypto/src/signature/mod.rs Show resolved Hide resolved
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
GhostOfGauss
GhostOfGauss previously approved these changes Aug 16, 2022
Copy link
Contributor

@BoyuanFeng BoyuanFeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • TODO:
    • Add a parameter to DiffieHellman to support a generator with a different type than the public key group type
    • Add associated type to HasGenerator which returns a custom type

Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
manta-crypto/src/accumulator.rs Outdated Show resolved Hide resolved
manta-crypto/src/accumulator.rs Show resolved Hide resolved
manta-crypto/src/arkworks/ff.rs Show resolved Hide resolved
manta-crypto/src/constraint.rs Outdated Show resolved Hide resolved
manta-crypto/src/eclair/alloc.rs Show resolved Hide resolved
manta-crypto/src/eclair/bool.rs Show resolved Hide resolved
manta-crypto/src/eclair/cmp.rs Show resolved Hide resolved
manta-crypto/src/eclair/cmp.rs Show resolved Hide resolved
manta-pay/Cargo.toml Show resolved Hide resolved
Copy link
Contributor

@SupremoUGH SupremoUGH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small remark: I didn't fully understand the field_try_into macro defined in arkworks::ff, so please check with someone else that everything's correct there.

manta-crypto/src/accumulator.rs Show resolved Hide resolved
manta-crypto/src/accumulator.rs Outdated Show resolved Hide resolved
manta-crypto/src/algebra.rs Show resolved Hide resolved
manta-crypto/src/algebra.rs Show resolved Hide resolved
manta-crypto/src/constraint.rs Show resolved Hide resolved
manta-crypto/src/eclair/alloc.rs Show resolved Hide resolved
manta-crypto/src/eclair/cmp.rs Show resolved Hide resolved
manta-crypto/src/eclair/cmp.rs Show resolved Hide resolved
manta-crypto/src/encryption/hybrid.rs Outdated Show resolved Hide resolved
manta-util/src/codec.rs Outdated Show resolved Hide resolved
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
SupremoUGH
SupremoUGH previously approved these changes Aug 19, 2022
Copy link
Contributor

@SupremoUGH SupremoUGH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my comments were addressed, approved.

Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
SupremoUGH
SupremoUGH previously approved these changes Aug 19, 2022
GhostOfGauss
GhostOfGauss previously approved these changes Aug 22, 2022
Copy link
Contributor

@BoyuanFeng BoyuanFeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only 1 minor typo.

manta-crypto/src/signature/mod.rs Outdated Show resolved Hide resolved
Signed-off-by: Boyuan Feng <boyuan@ucsb.edu>
BoyuanFeng
BoyuanFeng previously approved these changes Aug 22, 2022
SupremoUGH
SupremoUGH previously approved these changes Aug 22, 2022
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
@bhgomes bhgomes dismissed stale reviews from SupremoUGH and BoyuanFeng via b3d921c August 22, 2022 19:11
Signed-off-by: Brandon H. Gomes <bhgomes@pm.me>
@SupremoUGH SupremoUGH self-requested a review August 23, 2022 02:05
@bhgomes bhgomes merged commit 2e23763 into main Aug 23, 2022
@bhgomes bhgomes deleted the feat/crypto-upgrade branch August 23, 2022 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cryptography Area: Issues and PRs related to Cryptography changelog:added Changelog: add these changes to the `added` section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants