forked from ZenGo-X/zk-paillier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.rs
78 lines (60 loc) · 1.98 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
zk-paillier
Copyright 2018 by Kzen Networks
zk-paillier is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
@license GPL-3.0+ <https://github.com/KZen-networks/zk-paillier/blob/master/LICENSE>
*/
mod zero_enc_proof;
pub use self::zero_enc_proof::*;
mod correct_ciphertext;
pub use self::correct_ciphertext::*;
mod multiplication_proof;
pub use self::multiplication_proof::*;
mod verlin_proof;
pub use self::verlin_proof::*;
mod wi_dlog_proof;
pub use self::wi_dlog_proof::*;
mod correct_opening;
pub use self::correct_opening::CorrectOpening;
pub use self::correct_key::Challenge;
pub use self::correct_key::CorrectKeyProof;
pub use self::correct_key::VerificationAid;
mod correct_key;
pub use self::correct_key::CorrectKey;
pub use self::correct_key_ni::SALT_STRING;
mod correct_key_ni;
pub use self::correct_key_ni::CorrectKeyProofError;
pub use self::correct_key_ni::NICorrectKeyProof;
mod range_proof;
pub use self::range_proof::RangeProof;
pub use self::range_proof::RangeProofTrait;
pub use self::range_proof::ChallengeBits;
pub use self::range_proof::EncryptedPairs;
pub use self::range_proof::Proof;
mod range_proof_ni;
pub use self::range_proof_ni::RangeProofError;
pub use self::range_proof_ni::RangeProofNi;
mod correct_message;
pub use self::correct_message::CorrectMessageProof;
pub use self::correct_message::CorrectMessageProofError;
use std::borrow::Borrow;
use curv::arithmetic::traits::*;
use curv::BigInt;
use digest::Digest;
use sha2::Sha256;
pub fn compute_digest<'a, IT>(it: IT) -> BigInt
where
IT: Iterator,
IT::Item: Borrow<BigInt>,
{
let mut hasher = Sha256::new();
for value in it {
let bytes: Vec<u8> = value.borrow().to_bytes();
hasher.input(&bytes);
}
let result_bytes = hasher.result();
BigInt::from_bytes(&result_bytes[..])
}