Skip to content

Commit

Permalink
Sig
Browse files Browse the repository at this point in the history
  • Loading branch information
claucece committed Mar 26, 2024
1 parent e74cfbc commit 6660e95
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions acl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include = ["Cargo.toml", "src"]
[dependencies]
ark-ec = { version = "0.4.2", default-features = false }
ark-std = { version = "0.4.0", default-features = false }
pedersen = { path="../pedersen" }
rand = { version = "0.8.5" }
ark-ff = { version = "0.4.2"}
ark-serialize = { version = "0.4.2"}
Expand Down
47 changes: 45 additions & 2 deletions acl/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,54 @@
//! Module containing the definition of the private key container
//!
use crate::{config::ACLConfig, config::StateSignatureComm};
use ark_ec::{
models::CurveConfig,
short_weierstrass::{self as sw, SWCurveConfig},
AffineRepr, CurveGroup,
};
use rand::{CryptoRng, RngCore};

use digest::{ExtendableOutputDirty, Update, XofReader};
use crate::{config::ACLConfig, config::KeyPair, config::StateSignatureComm};
use ark_serialize::CanonicalSerialize;
use ark_std::{ops::Mul, UniformRand};
use pedersen::pedersen_config::PedersenComm;
use pedersen::pedersen_config::PedersenConfig;

/// SigComm. This struct acts as a container for the first message (the commitment) of the Signature.
pub struct SigComm<A: ACLConfig> {
/// rand: the first message value.
pub rand: <A as CurveConfig>::ScalarField,
/// a: the second message value.
pub a: sw::Affine<A>,
/// a1: the third message value.
pub a1: sw::Affine<A>,
/// a2: the fourth message value.
pub a2: sw::Affine<A>,
}

impl<A: ACLConfig> SigComm<A> {
/// create_message_one. This function creates the first signature message.
/// # Arguments
/// * `inter` - the intermediate values to use.
pub fn create_message_one<T: RngCore + CryptoRng>(
keys: KeyPair<A>,
rng: &mut T,
vals: Vec<<A as CurveConfig>::ScalarField>,
) -> SigComm<A> {
let comms = PedersenComm::new_multi(vals, rng);

let rand = <A as CurveConfig>::ScalarField::rand(rng);
let u = <A as CurveConfig>::ScalarField::rand(rng);
let r1 = <A as CurveConfig>::ScalarField::rand(rng);
let r2 = <A as CurveConfig>::ScalarField::rand(rng);
let c = <A as CurveConfig>::ScalarField::rand(rng);

let z1 = (A::GENERATOR.mul(rand) + comms.commitment()).into_affine();
let z2 = (keys.tag_key - z1).into_affine();
let a = (A::GENERATOR.mul(u)).into_affine();
let a1 = (A::GENERATOR.mul(r1) + z1.mul(c)).into_affine();
let a2 = (A::GENERATOR.mul(r2) + z2.mul(c)).into_affine();

Self { rand, a, a1, a2 }
}
}
4 changes: 4 additions & 0 deletions pedersen/src/pedersen_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,8 @@ impl<P: PedersenConfig> PedersenComm<P> {
r,
}
}

pub const fn commitment(&self) -> sw::Affine<P> {
self.comm
}
}

0 comments on commit 6660e95

Please sign in to comment.