Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Used espresso-systems-common for tagged_base64 constants #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ ark-serialize = { version = "0.3.0", default-features = false }
ark-ec = { version = "0.3.0", default-features = false }
ark-ff = { version = "0.3.0", default-features = false }
commit = { git = "https://github.com/EspressoSystems/commit.git", tag = "0.1.0" }
espresso-systems-common = { git = "https://github.com/EspressoSystems/espresso-systems-common.git", tag = "0.1.1" }
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_derive = { version = "1.0", default-features = false }
itertools = { version = "0.10.1", default-features = false }
jf-plonk = { features=["std"], git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.1" }
jf-rescue = { features=["std"], git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.1" }
jf-primitives = { features=["std"], git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.1" }
jf-utils = { git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.1" }
jf-plonk = { features=["std"], git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.2" }
jf-rescue = { features=["std"], git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.2" }
jf-primitives = { features=["std"], git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.2" }
jf-utils = { git = "https://github.com/EspressoSystems/jellyfish.git", tag = "0.1.2" }
sha2 = { version = "0.9.5", default-features = false }
structopt = { version = "0.3.22", default-features = false }
rand = { version = "0.8.4", default-features = false, features = [ "alloc" ] }
Expand Down
19 changes: 10 additions & 9 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use ark_std::{
vec::Vec,
UniformRand,
};
use espresso_systems_common::cap as tag;
use jf_primitives::{
aead, elgamal,
elgamal::EncKey,
Expand All @@ -56,7 +57,7 @@ use jf_utils::{hash_to_field, tagged_blob};
pub type UserAddress = schnorr::VerKey<CurveParam>;

/// The public key of a `UserKeyPair`
#[tagged_blob("USERPUBKEY")]
#[tagged_blob(tag::USERPUBKEY)]
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub struct UserPubKey {
pub(crate) address: UserAddress,
Expand Down Expand Up @@ -123,7 +124,7 @@ impl UserPubKey {
}

/// A key pair for the user who owns and can consume records (spend asset)
#[tagged_blob("USERKEY")]
#[tagged_blob(tag::USERKEY)]
#[derive(Debug, Default, Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct UserKeyPair {
pub(crate) addr_keypair: schnorr::KeyPair<CurveParam>,
Expand Down Expand Up @@ -191,7 +192,7 @@ impl UserKeyPair {
}

/// Public key for the credential issuer
#[tagged_blob("CREDPUBKEY")]
#[tagged_blob(tag::CREDPUBKEY)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default, CanonicalDeserialize, CanonicalSerialize)]
pub struct CredIssuerPubKey(pub(crate) schnorr::VerKey<CurveParam>);

Expand All @@ -215,7 +216,7 @@ impl CredIssuerPubKey {
}

/// Key pair for the credential issuer
#[tagged_blob("CREDKEY")]
#[tagged_blob(tag::CREDKEY)]
#[derive(Debug, Clone, Default, CanonicalSerialize, CanonicalDeserialize)]
pub struct CredIssuerKeyPair(pub(crate) schnorr::KeyPair<CurveParam>);

Expand Down Expand Up @@ -243,7 +244,7 @@ impl CredIssuerKeyPair {
}

/// Public key for the auditor
#[tagged_blob("AUDPUBKEY")]
#[tagged_blob(tag::AUDPUBKEY)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default, CanonicalDeserialize, CanonicalSerialize)]
pub struct AuditorPubKey(pub(crate) elgamal::EncKey<CurveParam>);

Expand All @@ -270,7 +271,7 @@ impl AuditorPubKey {
}
}
/// Key pair for the auditor
#[tagged_blob("AUDKEY")]
#[tagged_blob(tag::AUDKEY)]
#[derive(Debug, Clone, CanonicalDeserialize, CanonicalSerialize)]
pub struct AuditorKeyPair(pub(crate) elgamal::KeyPair<CurveParam>);

Expand Down Expand Up @@ -367,7 +368,7 @@ impl AuditorKeyPair {
}

/// Public key for the freezer
#[tagged_blob("FREEZEPUBKEY")]
#[tagged_blob(tag::FREEZEPUBKEY)]
#[derive(Clone, Debug, Eq, Default, CanonicalSerialize, CanonicalDeserialize)]
pub struct FreezerPubKey(pub(crate) GroupProjective<CurveParam>);

Expand All @@ -392,7 +393,7 @@ impl PartialEq for FreezerPubKey {
}

/// Key pair for the freezer
#[tagged_blob("FREEZEKEY")]
#[tagged_blob(tag::FREEZEKEY)]
#[derive(Clone, Debug, Default, CanonicalSerialize, CanonicalDeserialize)]
pub struct FreezerKeyPair {
pub(crate) sec_key: ScalarField,
Expand Down Expand Up @@ -468,7 +469,7 @@ fn compute_nullifier_key(

/// Secret key used to nullify records, can only be derived by either the record
/// owner (`UserKeyPair`) or the correct freezer (`FreezerKeyPair`)
#[tagged_blob("NULKEY")]
#[tagged_blob(tag::NULKEY)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub(crate) struct NullifierKey(pub(crate) BaseField);

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ use crate::{
use ark_serialize::*;
use ark_std::{boxed::Box, format, string::ToString, vec, vec::Vec};
use errors::TxnApiError;
use espresso_systems_common::cap as tag;
use freeze::FreezeNote;
use jf_plonk::{proof_system::structs::Proof, transcript::SolidityTranscript};
use jf_primitives::signatures::{schnorr::SchnorrSignatureScheme, SignatureScheme};
Expand Down Expand Up @@ -360,7 +361,7 @@ impl From<FreezeNote> for TransactionNote {

/// A transaction verifying key contains a proof verification key of possibly
/// various transaction types, including transfer, mint and freeze.
#[tagged_blob("TXVERKEY")]
#[tagged_blob(tag::TXVERKEY)]
#[derive(Debug, Clone)]
pub enum TransactionVerifyingKey {
/// verification key for validity proof in transfer note
Expand Down
23 changes: 12 additions & 11 deletions src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use ark_std::{
vec,
vec::Vec,
};
use espresso_systems_common::cap as tag;
use jf_primitives::{
aead,
commitment::Commitment as RescueCommitment,
Expand All @@ -55,14 +56,14 @@ pub enum NoteType {
}

/// A unique identifier/code for an asset type
#[tagged_blob("INTERNAL_ASSET_CODE")]
#[tagged_blob(tag::INTERNAL_ASSET_CODE)]
#[derive(
Debug, Clone, Copy, PartialEq, Default, CanonicalSerialize, CanonicalDeserialize, Hash, Eq,
)]
pub struct InternalAssetCode(pub(crate) BaseField);

/// The random seed used in AssetCode derivation
#[tagged_blob("ASSET_SEED")]
#[tagged_blob(tag::ASSET_SEED)]
#[derive(Debug, Copy, Clone, Default, CanonicalSerialize, CanonicalDeserialize, PartialEq)]
pub struct AssetCodeSeed(pub(crate) BaseField);

Expand Down Expand Up @@ -203,7 +204,7 @@ impl TryFrom<primitive_types::U256> for Amount {
}

/// Asset code structure
#[tagged_blob("ASSET_CODE")]
#[tagged_blob(tag::ASSET_CODE)]
#[derive(
Debug, Clone, Copy, PartialEq, Default, CanonicalSerialize, CanonicalDeserialize, Hash, Eq,
)]
Expand Down Expand Up @@ -691,7 +692,7 @@ impl AssetPolicy {
/// Asset Definition
/// * `code` -- asset code as unique id code
/// * `policy` -- asset policy attached
#[tagged_blob("ASSET_DEF")]
#[tagged_blob(tag::ASSET_DEF)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Default, CanonicalDeserialize, CanonicalSerialize)]
pub struct AssetDefinition {
/// asset code as unique id code
Expand Down Expand Up @@ -750,7 +751,7 @@ impl AssetDefinition {
pub(crate) type CommitmentValue = BaseField;

/// The blind factor used to produce a hiding commitment
#[tagged_blob("BLIND")]
#[tagged_blob(tag::BLIND)]
#[derive(
Copy, Clone, Debug, Default, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize,
)]
Expand All @@ -773,7 +774,7 @@ impl From<BaseField> for BlindFactor {
}

/// The nullifier represents a spent/consumed asset record
#[tagged_blob("NUL")]
#[tagged_blob(tag::NUL)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub struct Nullifier(pub(crate) BaseField);

Expand All @@ -788,7 +789,7 @@ impl Nullifier {
}

/// Asset record to be published
#[tagged_blob("REC")]
#[tagged_blob(tag::REC)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, CanonicalSerialize, CanonicalDeserialize)]
pub struct RecordCommitment(pub(crate) CommitmentValue);

Expand Down Expand Up @@ -1010,13 +1011,13 @@ impl RecordOpening {
}

// The actual credential which is basically a Schnorr signature over attributes
#[tagged_blob("CRED")]
#[tagged_blob(tag::CRED)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub(crate) struct Credential(pub(crate) Signature);

/// An identity attribute of a user, usually attested via `ExpirableCredential`
/// issued by an identity issuer.
#[tagged_blob("ID")]
#[tagged_blob(tag::ID)]
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub struct IdentityAttribute(pub(crate) BaseField);

Expand Down Expand Up @@ -1199,7 +1200,7 @@ impl ExpirableCredential {
/// Memos for auditors such as auditors required by the asset policy.
/// Concretely, it is a ciphertext over details of a
/// transaction, enabling asset tracing and identity tracing.
#[tagged_blob("AUDMEMO")]
#[tagged_blob(tag::AUDMEMO)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
pub struct AuditMemo(pub(crate) elgamal::Ciphertext<CurveParam>);

Expand Down Expand Up @@ -1507,7 +1508,7 @@ impl AuditData {
}
// TODO: (alex) add this after Philippe's MT MR merged
/// The proof of membership in an accumulator (Merkle tree) for an asset record
#[tagged_blob("RECMEMO")]
#[tagged_blob(tag::RECMEMO)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, CanonicalSerialize, CanonicalDeserialize)]
/// Encrypted Message for owners of transaction outputs
pub struct ReceiverMemo(pub(crate) aead::Ciphertext);
Expand Down