diff --git a/acl/Cargo.toml b/acl/Cargo.toml index 9158ce8..110aa8d 100644 --- a/acl/Cargo.toml +++ b/acl/Cargo.toml @@ -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"} diff --git a/acl/src/sign.rs b/acl/src/sign.rs index 086e025..999b66a 100644 --- a/acl/src/sign.rs +++ b/acl/src/sign.rs @@ -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 { + /// rand: the first message value. + pub rand: ::ScalarField, + /// a: the second message value. + pub a: sw::Affine, + /// a1: the third message value. + pub a1: sw::Affine, + /// a2: the fourth message value. + pub a2: sw::Affine, +} + +impl SigComm { + /// create_message_one. This function creates the first signature message. + /// # Arguments + /// * `inter` - the intermediate values to use. + pub fn create_message_one( + keys: KeyPair, + rng: &mut T, + vals: Vec<::ScalarField>, + ) -> SigComm { + let comms = PedersenComm::new_multi(vals, rng); + + let rand = ::ScalarField::rand(rng); + let u = ::ScalarField::rand(rng); + let r1 = ::ScalarField::rand(rng); + let r2 = ::ScalarField::rand(rng); + let c = ::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 } + } +} diff --git a/pedersen/src/pedersen_config.rs b/pedersen/src/pedersen_config.rs index c2db6b6..77ef2d2 100644 --- a/pedersen/src/pedersen_config.rs +++ b/pedersen/src/pedersen_config.rs @@ -553,4 +553,8 @@ impl PedersenComm

{ r, } } + + pub const fn commitment(&self) -> sw::Affine

{ + self.comm + } }