|
| 1 | +//nc1 |
| 2 | +use crate::ark_std::UniformRand; |
| 3 | +use crate::ark_std::Zero; |
| 4 | +use crate::Error; |
| 5 | +use crate::HomomorphicSignatureScheme; |
| 6 | +use ark_ec::pairing::Pairing; |
| 7 | +use ark_ec::AffineRepr; |
| 8 | +use ark_std::{marker::PhantomData, rand::Rng}; |
| 9 | +use digest::Digest; |
| 10 | +use std::ops::MulAssign; |
| 11 | + |
| 12 | +pub struct HolographicHomomorphicSignatureScheme<P: Pairing, D: Digest> { |
| 13 | + _pairing: PhantomData<P>, |
| 14 | + _hash: PhantomData<D>, |
| 15 | +} |
| 16 | + |
| 17 | +#[derive(Clone)] |
| 18 | +pub struct H2S2Parameters<P: Pairing> { |
| 19 | + pub g1_generators: Vec<P::G1>, |
| 20 | + pub g2_generator: P::G2, |
| 21 | +} |
| 22 | + |
| 23 | +impl<P: Pairing, D: Digest + Send + Sync> HolographicHomomorphicSignatureScheme for NC1<P, D> { |
| 24 | + type Parameters = H2S2Parameters<P>; |
| 25 | + type PublicKey = P::G2; |
| 26 | + type SecretKey = P::ScalarField; |
| 27 | + type Signature = P::G1; |
| 28 | + type Message = P::ScalarField; |
| 29 | + type Weight = usize; |
| 30 | + |
| 31 | + /// Generate G2 element and `n` G1 elements |
| 32 | + fn setup<R: Rng>(rng: &mut R, n: usize) -> Result<Self::Parameters, Error> {} |
| 33 | + |
| 34 | + /// Generate hash aggregate (H_a) with `tag` and `n` lanes |
| 35 | + fn precompute(tag: &[u8], n: usize) -> Result<P::G1, Error> {} |
| 36 | + |
| 37 | + /// Generate private and public receipt keys using `pp` parameters from `setup` |
| 38 | + fn keygen<R: Rng>( |
| 39 | + pp: &Self::Parameters, |
| 40 | + rng: &mut R, |
| 41 | + ) -> Result<(Self::PublicKey, Self::SecretKey), Error> { |
| 42 | + } |
| 43 | + |
| 44 | + /// Sign `message` with `tag` at `index` |
| 45 | + fn sign( |
| 46 | + pp: &Self::Parameters, |
| 47 | + sk: &Self::SecretKey, |
| 48 | + tag: &[u8], |
| 49 | + index: &[u8], |
| 50 | + message: &[Self::Message], |
| 51 | + ) -> Result<Self::Signature, Error> { |
| 52 | + } |
| 53 | + |
| 54 | + /// Verify a single `signature` matches `message` with `tag` at `index` using `pp` parameter and `pk` public key |
| 55 | + fn verify( |
| 56 | + pp: &Self::Parameters, |
| 57 | + pk: &Self::PublicKey, |
| 58 | + tag: &[u8], |
| 59 | + index: &[u8], |
| 60 | + message: &[Self::Message], |
| 61 | + signature: &Self::Signature, |
| 62 | + ) -> Result<bool, Error> { |
| 63 | + } |
| 64 | + |
| 65 | + /// Verify aggregate `signature` matches `message_aggregate` with `tag` and `hash_aggregate`using `pp` parameter and `pk` public key |
| 66 | + fn verify_aggregate( |
| 67 | + pp: &Self::Parameters, |
| 68 | + pk: &Self::PublicKey, |
| 69 | + tag: &[u8], |
| 70 | + message_aggregate: &[Self::Message], |
| 71 | + hash_aggregate: &P::G1, |
| 72 | + signature: &Self::Signature, |
| 73 | + ) -> Result<bool, Error> { |
| 74 | + } |
| 75 | + |
| 76 | + /// Aggregate `signatures` with `weights` |
| 77 | + fn evaluate( |
| 78 | + signatures: &[Self::Signature], |
| 79 | + weights: &[Self::Weight], |
| 80 | + ) -> Result<Self::Signature, Error> { |
| 81 | + } |
| 82 | +} |
0 commit comments