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

Implements #31 - Generators available as extended #34

Merged
merged 3 commits into from
Aug 13, 2020
Merged
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
33 changes: 32 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#![no_std]
// Catch documentation errors caused by code changes.
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GH actions doesn't seem to understant that lint. It's fine if it works anyway

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They renamed this recently to broken_intra_doc_links

rust-lang/rust#74926

With a updated nightly you should receive a warning/error if using intra_doc_link_resolution_failure

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![deny(unsafe_code)]
Expand Down Expand Up @@ -124,6 +124,15 @@ pub const GENERATOR: AffinePoint = AffinePoint {
]),
};

/// [`GENERATOR`] in [`ExtendedPoint`] form
pub const GENERATOR_EXTENDED: ExtendedPoint = ExtendedPoint {
x: GENERATOR.x,
y: GENERATOR.y,
z: Fq::one(),
t1: GENERATOR.x,
t2: GENERATOR.y,
};

/// GENERATOR NUMS which is obtained following the specs in:
/// https://app.gitbook.com/@dusk-network/s/specs/specifications/poseidon/pedersen-commitment-scheme
/// The counter = 18 and the hash function used to compute it was blake2b
Expand All @@ -145,6 +154,15 @@ pub const GENERATOR_NUMS: AffinePoint = AffinePoint {
]),
};

/// [`GENERATOR_NUMS`] in [`ExtendedPoint`] form
pub const GENERATOR_NUMS_EXTENDED: ExtendedPoint = ExtendedPoint {
x: GENERATOR_NUMS.x,
y: GENERATOR_NUMS.y,
z: Fq::one(),
t1: GENERATOR_NUMS.x,
t2: GENERATOR_NUMS.y,
};

// 202, 234, 123, 236, 255, 183, 247, 77, 237, 84, 108, 253, 33, 187, 62, 46,
// 230, 204, 214,15, 45, 240, 251, 241, 166, 101, 172, 67, 76, 129, 210, 63,

Expand Down Expand Up @@ -1017,6 +1035,11 @@ fn test_affine_point_generator_has_order_p() {
assert_eq!(GENERATOR.is_prime_order().unwrap_u8(), 1);
}

#[test]
fn test_extended_point_generator_has_order_p() {
assert_eq!(GENERATOR_EXTENDED.is_prime_order().unwrap_u8(), 1);
}

#[test]
fn test_affine_point_generator_nums_has_order_p() {
assert_eq!(GENERATOR_NUMS.is_prime_order().unwrap_u8(), 1);
Expand All @@ -1030,6 +1053,14 @@ fn test_affine_point_generator_is_not_identity() {
);
}

#[test]
fn test_extended_point_generator_is_not_identity() {
assert_ne!(
GENERATOR_EXTENDED.mul_by_cofactor(),
ExtendedPoint::identity()
);
}

#[test]
fn test_affine_point_generator_nums_is_not_identity() {
assert_ne!(
Expand Down