Skip to content

Commit f7b1446

Browse files
authored
Merge pull request #5 from semiotic-ai/empty-api
defines initial framework
2 parents 9af5c8d + 48e41d3 commit f7b1446

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[workspace]
2+
members = [
3+
"h2s2",
4+
]

h2s2/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "h2s2"
3+
version = "0.1.0"
4+
authors = [
5+
"Bryan Cole <bryan.cole@semiotic.ai>",
6+
"Severiano Sisneros <severiano@semiotic.ai>",
7+
"Alexis Asseman <alexis@semiotic.ai>",
8+
"Tomasz Kornuta <tomasz@semiotic.ai>",
9+
]
10+
license = "Apache-2.0"
11+
description = ""
12+
edition = "2021"
13+
keywords = ["holographic", "homomorphic", "signature-scheme"]
14+
catagories = ["cryptography", "cryptography::cryptocurrencies"]
15+
16+
17+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
18+
19+
[dependencies]
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
}

h2s2/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: usize, right: usize) -> usize {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

0 commit comments

Comments
 (0)