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

Feat: new circuits part 1 #276

Merged
merged 6 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]
### Added
- [#276](https://github.com/Manta-Network/manta-rs/pull/276) New circuits part 1: manta-crypto abstractions

### Changed

Expand Down
14 changes: 7 additions & 7 deletions manta-accounting/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use core::{
marker::PhantomData,
};
use manta_crypto::{
key::kdf::KeyDerivationFunction,
key::agreement::Derive,
SupremoUGH marked this conversation as resolved.
Show resolved Hide resolved
rand::{RngCore, Sample},
};
use manta_util::collections::btree_map::{self, BTreeMap};
Expand Down Expand Up @@ -168,7 +168,7 @@ pub trait HierarchicalKeyDerivationScheme {
fn map<F>(self, key_derivation_function: F) -> Map<Self, F>
where
Self: Sized,
F: KeyDerivationFunction<Key = Self::SecretKey>,
F: Derive<SecretKey = Self::SecretKey>,
{
Map::new(self, key_derivation_function)
}
Expand Down Expand Up @@ -209,7 +209,7 @@ where
pub struct Map<H, F>
where
H: HierarchicalKeyDerivationScheme,
F: KeyDerivationFunction<Key = H::SecretKey>,
F: Derive<SecretKey = H::SecretKey>,
{
/// Base Derivation Scheme
base: H,
Expand All @@ -221,7 +221,7 @@ where
impl<H, F> Map<H, F>
where
H: HierarchicalKeyDerivationScheme,
F: KeyDerivationFunction<Key = H::SecretKey>,
F: Derive<SecretKey = H::SecretKey>,
{
/// Builds a new [`Map`] from `base` and `key_derivation_function`.
#[inline]
Expand All @@ -236,11 +236,11 @@ where
impl<H, F> HierarchicalKeyDerivationScheme for Map<H, F>
where
H: HierarchicalKeyDerivationScheme,
F: KeyDerivationFunction<Key = H::SecretKey>,
F: Derive<SecretKey = H::SecretKey>,
{
const GAP_LIMIT: IndexType = H::GAP_LIMIT;

type SecretKey = F::Output;
type SecretKey = F::PublicKey;

#[inline]
fn derive(&self, account: AccountIndex, kind: Kind, index: KeyIndex) -> Self::SecretKey {
Expand All @@ -264,7 +264,7 @@ where
impl<H, F, D> Sample<(D, F)> for Map<H, F>
where
H: HierarchicalKeyDerivationScheme + Sample<D>,
F: KeyDerivationFunction<Key = H::SecretKey>,
F: Derive<SecretKey = H::SecretKey>,
{
#[inline]
fn sample<R>(distribution: (D, F), rng: &mut R) -> Self
Expand Down
13 changes: 10 additions & 3 deletions manta-accounting/src/transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ pub trait Configuration {
type PublicKey: Clone;

/// Key Agreement Scheme Type
type KeyAgreementScheme: key::agreement::Types<SecretKey = SecretKey<Self>, PublicKey = PublicKey<Self>>
type KeyAgreementScheme: key::agreement::SecretKeyType<SecretKey = SecretKey<Self>>
+ key::agreement::PublicKeyType<PublicKey = PublicKey<Self>>
+ key::agreement::EphemeralPublicKeyType<EphemeralPublicKey = PublicKey<Self>>
+ key::agreement::EphemeralSecretKeyType<EphemeralSecretKey = SecretKey<Self>>
+ key::agreement::ReconstructSecret
+ key::agreement::Agree
+ key::agreement::Derive;
+ key::agreement::Derive
+ key::agreement::DeriveEphemeral
+ key::agreement::GenerateSecret;

/// Secret Key Variable Type
type SecretKeyVar: Variable<Secret, Self::Compiler, Type = SecretKey<Self>>;
Expand All @@ -139,7 +145,8 @@ pub trait Configuration {

/// Key Agreement Scheme Variable Type
type KeyAgreementSchemeVar: Constant<Self::Compiler, Type = Self::KeyAgreementScheme>
+ key::agreement::Types<SecretKey = SecretKeyVar<Self>, PublicKey = PublicKeyVar<Self>>
+ key::agreement::SecretKeyType<SecretKey = SecretKeyVar<Self>>
SupremoUGH marked this conversation as resolved.
Show resolved Hide resolved
+ key::agreement::PublicKeyType<PublicKey = PublicKeyVar<Self>>
+ key::agreement::Agree<Self::Compiler>
+ key::agreement::Derive<Self::Compiler>;

Expand Down
1 change: 1 addition & 0 deletions manta-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ std = [
"ark-relations?/std",
"ark-serialize?/std",
"manta-util/std",
"rand?/std",
"rand_chacha?/std",
]

Expand Down
2 changes: 1 addition & 1 deletion manta-crypto/src/accumulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use core::{fmt::Debug, hash::Hash};
/// Accumulator Membership Model Types
pub trait Types {
/// Item Type
type Item: ?Sized;
type Item;

/// Secret Witness Type
type Witness;
Expand Down
Loading