瀏覽代碼

Include the Arctic public key as a field of its secret key to match the paper

Ian Goldberg 3 月之前
父節點
當前提交
14e5ca3d45
共有 2 個文件被更改,包括 10 次插入8 次删除
  1. 9 7
      src/arctic.rs
  2. 1 1
      src/bin/arctic.rs

+ 9 - 7
src/arctic.rs

@@ -14,6 +14,7 @@ pub struct SecKey {
     k: u32,
     sk: Scalar,
     rk: shine::PreprocKey,
+    pk: PubKey,
 }
 
 impl SecKey {
@@ -42,6 +43,7 @@ pub fn keygen(n: u32, t: u32) -> (PubKey, Vec<SecKey>) {
             k,
             sk: shamirpoly.eval(&Scalar::from(k)),
             rk: shine::PreprocKey::preproc(&shinekeys[(k as usize) - 1]),
+            pk: pubkey,
         });
     }
 
@@ -65,9 +67,9 @@ fn hash3(combcomm: &RistrettoPoint, pk: &PubKey, msg: &[u8]) -> Scalar {
     Scalar::from_bytes_mod_order(hashval)
 }
 
-pub fn sign1(pk: &PubKey, sk: &SecKey, coalition: &[u32], msg: &[u8]) -> RistrettoPoint {
+pub fn sign1(sk: &SecKey, coalition: &[u32], msg: &[u8]) -> RistrettoPoint {
     assert!(coalition.len() >= 2 * (sk.t as usize) - 1);
-    let w = hash2(pk, msg);
+    let w = hash2(&sk.pk, msg);
     sk.rk.gen(&w).1
 }
 
@@ -170,7 +172,7 @@ pub fn test_arctic_good() {
 
     let commits: Vec<RistrettoPoint> = seckeys
         .iter()
-        .map(|key| sign1(&pubkey, key, &coalition, msg))
+        .map(|key| sign1(key, &coalition, msg))
         .collect();
 
     let sigshares: Vec<Scalar> = seckeys
@@ -197,7 +199,7 @@ pub fn test_arctic_bad1() {
 
     let mut commits: Vec<RistrettoPoint> = seckeys
         .iter()
-        .map(|key| sign1(&pubkey, key, &coalition, msg))
+        .map(|key| sign1(key, &coalition, msg))
         .collect();
 
     // Modify player 1's commitment
@@ -222,7 +224,7 @@ pub fn test_arctic_bad2() {
 
     let mut commits: Vec<RistrettoPoint> = seckeys
         .iter()
-        .map(|key| sign1(&pubkey, key, &coalition, msg))
+        .map(|key| sign1(key, &coalition, msg))
         .collect();
 
     // Modify player 1's commitment
@@ -247,7 +249,7 @@ pub fn test_arctic_bad3() {
 
     let commits: Vec<RistrettoPoint> = seckeys
         .iter()
-        .map(|key| sign1(&pubkey, key, &coalition, msg))
+        .map(|key| sign1(key, &coalition, msg))
         .collect();
 
     let mut sigshares: Vec<Scalar> = seckeys
@@ -279,7 +281,7 @@ pub fn test_arctic_bad4() {
 
     let commits: Vec<RistrettoPoint> = seckeys
         .iter()
-        .map(|key| sign1(&pubkey, key, &coalition, msg))
+        .map(|key| sign1(key, &coalition, msg))
         .collect();
 
     let sigshares: Vec<Scalar> = seckeys

+ 1 - 1
src/bin/arctic.rs

@@ -67,7 +67,7 @@ fn main() {
             .iter()
             .map(|key| {
                 let sign1start = Instant::now();
-                let commitment = arctic::sign1(&pubkey, key, &coalition, &msg);
+                let commitment = arctic::sign1(key, &coalition, &msg);
                 let sign1dur = sign1start.elapsed().as_micros() as f64;
                 (commitment, sign1dur)
             })