Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/pedersen-commitments #1048

Merged
merged 55 commits into from
Mar 11, 2022
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a88be3d
add pedersen.rs and first alias type
danielementary Dec 20, 2021
70f010d
replace ciphertexts in BlindSignRequest by commitments and adapt try_…
danielementary Dec 20, 2021
15c4698
update BlindSignRequest.to_byte_vec
danielementary Dec 20, 2021
b063792
add TODO to issuance.rs
danielementary Dec 20, 2021
90af724
[WIP] update CmCs proof to use commitments
danielementary Dec 20, 2021
978557b
complete ProofCmCs construct implementation
danielementary Dec 21, 2021
e36d621
[WIP] ProofCmCs verify
danielementary Dec 21, 2021
cefd289
complete ProofCmCs verify implementation
danielementary Dec 21, 2021
42a8c04
complete ProofCmCs to_bytes implementation
danielementary Dec 21, 2021
4c6ed27
complete ProofCmCs from_bytes implementation
danielementary Dec 21, 2021
5cb2787
WIP update ProofCmCs roundtrip tests
danielementary Dec 21, 2021
181f71a
WIP update prepare_blind_sign
danielementary Dec 21, 2021
d7db819
update prepare_blind_sign
danielementary Dec 22, 2021
404d4b8
WIP update blind_sign
danielementary Dec 22, 2021
da94f0d
update blind_sign
danielementary Dec 22, 2021
694c4a1
update BlindedSignature and try_from
danielementary Dec 22, 2021
dcf0572
update BlindedSignature unblind
danielementary Dec 22, 2021
4d07b9f
update BlindedSignature to_bytes
danielementary Dec 22, 2021
4c81ee1
move elgamal encrypto to elgamal and manage imports
danielementary Dec 22, 2021
53a09ad
add verification keys for g1 method
danielementary Dec 22, 2021
9ba550e
upadate tests to work with Pedersen commitments
danielementary Dec 22, 2021
6ba9fca
unused remove pedersen.rs
danielementary Dec 22, 2021
690f83c
update error message
danielementary Dec 22, 2021
5b2dfbc
fix proof_cm_cs_bytes_roundtrip test
danielementary Dec 22, 2021
d34433a
Move generation of commitment openings into prepare blind signature f…
aniampio Jan 4, 2022
14fc663
Edits
aniampio Jan 6, 2022
ba9ad4d
Extende the verification key; remove validator's secret key from the …
aniampio Jan 6, 2022
500789b
Update the unblind function throughout the whole nymcoconut repo
aniampio Jan 6, 2022
184e8cc
Fix broken tests
aniampio Jan 7, 2022
3c441f1
Run cargo clippy and fmt
aniampio Jan 7, 2022
43ceb66
Add benchmark measurements
aniampio Jan 7, 2022
8ab6dac
Add more detailed printouts
aniampio Jan 14, 2022
4b88bed
Change byte printout
aniampio Jan 14, 2022
008a6f6
Update benchmarks
aniampio Jan 18, 2022
29ad8e3
add public attributes as part of the commitment
danielementary Jan 24, 2022
bd5a483
update bytes order comment for ProofCmCs
danielementary Jan 24, 2022
d76e238
check proof_cm_cs_bytes_roundtrip test and remove TODO
danielementary Jan 24, 2022
77b6cdd
remove irrelevant prints in blind signature tests
danielementary Jan 24, 2022
e323017
remove inappropriate function to get betas_g1
danielementary Jan 24, 2022
35b4bf8
remove irrelevant prints in verification
danielementary Jan 24, 2022
2eefaf3
Remove print statement and add additional checks on the verification key
aniampio Mar 9, 2022
efb2124
Run clippy
aniampio Mar 9, 2022
5296203
Fix coconut call in validator-api
aniampio Mar 9, 2022
ae6a524
Update dependend packages
aniampio Mar 9, 2022
a9d53aa
Merge branch 'develop' into feature/pedersen-commitments
aniampio Mar 9, 2022
dcaefe4
Update the input to the obtain partial credential function
aniampio Mar 9, 2022
a3b69ed
Fix the verification key bytes calculation
aniampio Mar 9, 2022
47f1b83
Run cargo fmt on keygen.rs
aniampio Mar 9, 2022
571f1bb
Run cargo fmt for validator-api
aniampio Mar 9, 2022
f01c237
Run cargo fmt for credentials
aniampio Mar 9, 2022
57651e2
Replace concat with chain
aniampio Mar 10, 2022
226a875
Remove unneccessary mut
aniampio Mar 10, 2022
f2398b5
Merge branch 'develop' into feature/pedersen-commitments
aniampio Mar 10, 2022
9b4c4c7
Run cargo fmt
aniampio Mar 10, 2022
00d6877
fix type conversion
aniampio Mar 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions common/nymcoconut/src/scheme/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl TryFrom<&[u8]> for SecretKey {
type Error = CoconutError;

fn try_from(bytes: &[u8]) -> Result<SecretKey> {
// There should be x and at least one y
if bytes.len() < 32 * 2 + 8 || (bytes.len() - 8) % 32 != 0 {
return Err(CoconutError::DeserializationInvalidLength {
actual: bytes.len(),
Expand Down Expand Up @@ -125,28 +126,28 @@ impl TryFrom<&[u8]> for VerificationKey {
type Error = CoconutError;

fn try_from(bytes: &[u8]) -> Result<VerificationKey> {
// There should be at least alpha, one betaG1 and one betaG2
// There should be at least alpha, one betaG1 and one betaG2 and their length
if bytes.len() < 96 * 2 + 48 + 8 || (bytes.len() - 8 - 96) % (96 + 48) != 0 {
return Err(CoconutError::DeserializationInvalidLength {
actual: bytes.len(),
modulus_target: bytes.len() - 8 - 96,
target: 96 * 2 + 48 + 8,
modulus: 96 + 48,
object: "secret key".to_string(),
object: "verification key".to_string(),
});
}

// this conversion will not fail as we are taking the same length of data
let alpha_bytes: [u8; 96] = bytes[..96].try_into().unwrap();
let beta_len = u64::from_le_bytes(bytes[96..104].try_into().unwrap());
let betas_len = u64::from_le_bytes(bytes[96..104].try_into().unwrap());

let actual_betas_len = (bytes.len() - 104) / (96 + 48);

if beta_len as usize != actual_betas_len {
if betas_len as usize != actual_betas_len {
return Err(
CoconutError::Deserialization(
format!("Tried to deserialize verification key with inconsistent betas len (expected {}, got {})",
beta_len, actual_betas_len
betas_len, actual_betas_len
)));
}

Expand All @@ -157,9 +158,9 @@ impl TryFrom<&[u8]> for VerificationKey {
),
)?;

let mut beta_g1 = Vec::with_capacity(beta_len as usize);
let mut beta_g1 = Vec::with_capacity(betas_len as usize);
let mut beta_g1_end: u64 = 0;
for i in 0..beta_len {
for i in 0..betas_len {
let start = (104 + i * 48) as usize;
let end = (start + 48) as usize;
let beta_i_bytes = bytes[start..end].try_into().unwrap();
Expand All @@ -174,10 +175,10 @@ impl TryFrom<&[u8]> for VerificationKey {
beta_g1.push(beta_i)
}

let mut beta_g2 = Vec::with_capacity(beta_len as usize);
for i in 0..beta_len {
let mut beta_g2 = Vec::with_capacity(betas_len as usize);
for i in 0..betas_len {
let start = (beta_g1_end + i * 96) as usize;
let end = start + 96;
let end = (start + 96) as usize;
let beta_i_bytes = bytes[start..end].try_into().unwrap();
let beta_i = try_deserialize_g2_projective(
&beta_i_bytes,
Expand Down Expand Up @@ -316,7 +317,7 @@ impl VerificationKey {
let beta_g1_len = self.beta_g1.len() as u64;
let beta_g2_len = self.beta_g2.len() as u64;
let mut bytes = Vec::with_capacity(
8 + (beta_g1_len + 1) as usize * 48 + (beta_g2_len + 1) as usize + 96,
96 + 8 + beta_g1_len as usize * 48 + beta_g2_len as usize * 96,
);
aniampio marked this conversation as resolved.
Show resolved Hide resolved

bytes.extend_from_slice(&self.alpha.to_affine().to_compressed());
Expand Down