Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions p256/tests/projective.proptest-regressions
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
# It is recommended to check this file in to source control so that
# everyone who runs the test benefits from these saved cases.
cc e19ee42c127b7289fbe7e42df47abf141eb644afcbd13ac141e39b9960362174 # shrinks to point = ProjectivePoint { x: FieldElement(0x823CD15F6DD3C71933565064513A6B2BD183E554C6A08622F713EBBBFACE98BE), y: FieldElement(0x55DF5D5850F47BAD82149139979369FE498A9022A412B5E0BEDD2CFC21C3ED91), z: FieldElement(0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5) }, scalar = Scalar(0x0000000000000000000000000000000000000000000000000000000000000001)
cc 67d76546dee30db7f75f666ed335f84d90da4ce8775d612dcdb88a3058ef7071 # shrinks to point = ProjectivePoint { x: FieldElement(0x823CD15F6DD3C71933565064513A6B2BD183E554C6A08622F713EBBBFACE98BE), y: FieldElement(0x55DF5D5850F47BAD82149139979369FE498A9022A412B5E0BEDD2CFC21C3ED91), z: FieldElement(0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5) }, scalar = Scalar(0xAE74000000000000000000000000000000000000000000000000000000000000)
20 changes: 19 additions & 1 deletion primeorder/src/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,25 @@ where
FieldBytes<C>: Copy,
{
fn recommended_wnaf_for_num_scalars(num_scalars: usize) -> usize {
todo!()
// Empirical heuristic from the zcash/bellman implementation.
if num_scalars >= 32 {
3
} else if num_scalars >= 1 {
2
} else {
4
}
}

fn scalar_repr_to_le_bytes(
repr: &<Scalar<C> as PrimeField>::Repr,
) -> Vec<u8> {
// SEC1/NIST curves use big-endian scalar representations;
// reverse to get little-endian for wNAF decomposition.
let mut le: Vec<u8> =
AsRef::<[u8]>::as_ref(repr).to_vec();
le.reverse();
le
}
}

Expand Down
Loading