Advertisement
namuyan

schnorr_diff.patch

Jul 25th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 7.70 KB | None | 0 0
  1. Index: Cargo.toml
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- Cargo.toml  (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  7. +++ Cargo.toml  (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  8. @@ -17,7 +17,8 @@
  9.  num-traits = "0.2.6"
  10.  
  11.  [dependencies.emerald-city]
  12. -git = "https://github.com/KZen-networks/emerald-city"
  13. +git = "https://github.com/elichai/emerald-city"
  14. +branch = "secp"
  15.  
  16.  [dependencies.pyo3]
  17.  version = "0.7.0"
  18. Index: aggregate_1_of_1.py
  19. IDEA additional info:
  20. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  21. <+>UTF-8
  22. ===================================================================
  23. --- aggregate_1_of_1.py (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  24. +++ aggregate_1_of_1.py (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  25. @@ -1,20 +1,20 @@
  26.  from multi_party_schnorr import PyKeyPair, verify_aggregate_sign, verify_auto
  27.  from time import time
  28.  
  29. +PyKeyPair()
  30.  s = time()
  31.  msg = b"nice meet"
  32.  keypair = PyKeyPair()  # 18mS
  33. -print(round((time()-s)*1000), "mSec")
  34. +print(round((time()-s)*1000000000), "nSec")
  35.  pk = keypair.get_public_key()
  36. -print(round((time()-s)*1000), "mSec")
  37. +print(round((time()-s)*1000000000), "nSec")
  38.  print("key:", pk.hex())
  39.  R, sig = keypair.get_single_sign(msg)  # 19ms
  40. -print(round((time()-s)*1000), "mSec")
  41. +print(round((time()-s)*1000000000), "nSec")
  42.  print("R:", R.hex())
  43.  print("sig:", sig.hex())
  44.  result = verify_aggregate_sign(sig, R, pk, msg)  # 35ms
  45. -print(round((time()-s)*1000), "mSec")
  46. +print(round((time()-s)*1000000000), "nSec")
  47.  print("res:", result)
  48.  print("verify auto?", verify_auto(sig, R, pk, msg))
  49. -print(round((time()-s)*1000), "mSec")
  50. -
  51. +print(round((time()-s)*1000000000), "nSec")
  52. Index: aggregate_n_of_n.py
  53. IDEA additional info:
  54. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  55. <+>UTF-8
  56. ===================================================================
  57. --- aggregate_n_of_n.py (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  58. +++ aggregate_n_of_n.py (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  59. @@ -1,6 +1,7 @@
  60.  import multi_party_schnorr
  61.  from time import time
  62.  
  63. +multi_party_schnorr.PyKeyPair()
  64.  start = time()
  65.  pair0 = multi_party_schnorr.PyKeyPair()  # 27mS
  66.  pair1 = multi_party_schnorr.PyKeyPair()
  67. @@ -30,4 +31,4 @@
  68.  res = multi_party_schnorr.verify_aggregate_sign(sig012, R, apk, msg)  # 35.5mS
  69.  print("result:", res)
  70.  print("verify auto?", multi_party_schnorr.verify_auto(sig012, R, apk, msg))
  71. -print(int((time() - start) * 1000), "mS")
  72. +print(int((time() - start) * 1000000000), "nS")
  73. Index: src/modules.rs
  74. IDEA additional info:
  75. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  76. <+>UTF-8
  77. ===================================================================
  78. --- src/modules.rs  (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  79. +++ src/modules.rs  (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  80. @@ -108,7 +108,7 @@
  81.  fn summarize_public_points(_py: Python, signers: &PyList) -> PyResult<PyObject> {
  82.      let signers = pylist2points(&signers)?;
  83.      let sum = sum_public_points(&signers)?;
  84. -    let mut sum = sum.get_element().serialize_compressed();
  85. +    let mut sum = sum.get_element().serialize();
  86.      sum[0] += 6;  // 0x02 0x03 0x04 => 0x08 0x09 0x0a
  87.      Ok(PyBytes::new(_py, &sum).to_object(_py))
  88.  }
  89. Index: src/pyagg.rs
  90. IDEA additional info:
  91. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  92. <+>UTF-8
  93. ===================================================================
  94. --- src/pyagg.rs    (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  95. +++ src/pyagg.rs    (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  96. @@ -128,7 +128,7 @@
  97.      }
  98.  
  99.      fn apk(&self, _py: Python) -> PyObject {
  100. -        let mut bytes = self.apk.get_element().serialize_compressed();
  101. +        let mut bytes = self.apk.get_element().serialize();
  102.          if self.is_musig {
  103.              bytes[0] += 3; // 0x02 0x03 0x04 => 0x05 0x06 0x07
  104.          }
  105. Index: src/pykeypair.rs
  106. IDEA additional info:
  107. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  108. <+>UTF-8
  109. ===================================================================
  110. --- src/pykeypair.rs    (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  111. +++ src/pykeypair.rs    (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  112. @@ -42,7 +42,7 @@
  113.      }
  114.  
  115.      fn get_public_key(&self, _py: Python) -> PyObject {
  116. -        let public = self.public.get_element().serialize_compressed();
  117. +        let public = self.public.get_element().serialize();
  118.          PyBytes::new(_py, &public).to_object(_py)
  119.      }
  120.  
  121. @@ -80,7 +80,7 @@
  122.      fn get_shared_point(&self, _py: Python, public: &PyBytes) -> PyResult<PyObject> {
  123.          let public: GE = bytes2point(public.as_bytes())?;
  124.          let point: GE = public.scalar_mul(&self.secret.get_element());
  125. -        let point = point.get_element().serialize_compressed();
  126. +        let point = point.get_element().serialize();
  127.          Ok(PyObject::from(PyBytes::new(_py, &point)))
  128.      }
  129.  }
  130. Index: src/pyo3utils.rs
  131. IDEA additional info:
  132. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  133. <+>UTF-8
  134. ===================================================================
  135. --- src/pyo3utils.rs    (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  136. +++ src/pyo3utils.rs    (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  137. @@ -40,9 +40,9 @@
  138.                      PyKeyType::AggregateSig => template[0] -= 3,
  139.                      PyKeyType::ThresholdSig => template[0] -= 6
  140.                  }
  141. -                let public = PK::parse_compressed(&template).map_err(
  142. +                let public = PK::from_slice(&template).map_err(
  143.                      |_| format!("0 invalid pk point: {}", hex_bytes))?;
  144. -                GE::from_bytes(&public.serialize()[1..]).map_err(
  145. +                GE::from_bytes(&public.serialize_uncompressed()[1..]).map_err(
  146.                      |_| format!("1 invalid pk point: {}", hex_bytes))
  147.              }else if len == 65 && prefix == 4 {
  148.                  GE::from_bytes(&bytes[1..]).map_err(
  149. Index: src/pythreshold.rs
  150. IDEA additional info:
  151. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  152. <+>UTF-8
  153. ===================================================================
  154. --- src/pythreshold.rs  (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  155. +++ src/pythreshold.rs  (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  156. @@ -98,7 +98,7 @@
  157.                  self.t, self.n, &self.keypair.secret, &self.parties_index);
  158.  
  159.          let vss_point: Vec<&PyBytes> = vss_scheme.commitments.iter()
  160. -            .map(|com| PyBytes::new(_py, &com.get_element().serialize_compressed()))
  161. +            .map(|com| PyBytes::new(_py, &com.get_element().serialize()))
  162.              .collect();
  163.          let secret_scalar: Vec<&PyBytes> = secret_shares.iter()
  164.              .map(|int| PyBytes::new(_py, &bigint2bytes(&int.to_big_int()).unwrap()))
  165. Index: threshold_t_of_n.py
  166. IDEA additional info:
  167. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  168. <+>UTF-8
  169. ===================================================================
  170. --- threshold_t_of_n.py (revision 2828cf9da3f7ef94302a57fccbaadf7f1ee0f0f9)
  171. +++ threshold_t_of_n.py (revision 61d8cb5561d201c11b9e0b9e18d68f287608046d)
  172. @@ -1,6 +1,7 @@
  173.  import multi_party_schnorr
  174.  from time import time
  175.  
  176. +multi_party_schnorr.PyKeyPair()
  177.  start = time()
  178.  t = 2  # threshold
  179.  n = 5  # signers
  180. @@ -83,5 +84,5 @@
  181.  sign_start = time()
  182.  r = multi_party_schnorr.verify_threshold_sign(sigma, Y, V, msg)
  183.  print("verify?", r, round((time()-sign_start)*1000), "mSec")
  184. -print("finish", round(time() - start, 3), "Sec")
  185. +print("finish", int((time() - start)*1000), "mSec")
  186.  print("verify auto?", multi_party_schnorr.verify_auto(sigma, V, Y, msg))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement