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

Document Cofactor multiplied base points? #706

Open
stevefan1999-personal opened this issue Sep 24, 2024 · 0 comments
Open

Document Cofactor multiplied base points? #706

stevefan1999-personal opened this issue Sep 24, 2024 · 0 comments

Comments

@stevefan1999-personal
Copy link

stevefan1999-personal commented Sep 24, 2024

Derived from #705 and some discussion online, I find this constant particularly useful:

const ED25519_BASEPOINT_POINT_MUL_BY_COFACTOR: EdwardsPoint = EdwardsPoint{
    X: FieldElement51::from_limbs([2233581206391315, 847321536719855, 1143763522071466, 2176635986873503, 544015092356874]),
    Y: FieldElement51::from_limbs([810168548829118, 1091277158180317, 1905862677914949, 871313444918061, 2245667822025877]),
    Z: FieldElement51::from_limbs([207037345464830, 1993080251615457, 560932193579569, 999626924140364, 754134581836708]),
    T: FieldElement51::from_limbs([606549093027129, 120708372070681, 50079640475349, 1940797268843777, 623236962379938])
};

This is because in my way to generate ed25519 keys:

let ED25519_BASEPOINT_POINT_MUL_BY_COFACTOR = ED25519_BASEPOINT_POINT.mul_by_cofactor(); // Not constant at the moment

let mut rng = Rng::new();
let expanded_sk: [u8; 32] = 
    Sha512::default()
        .chain_update({
            let mut sk = SecretKey::default();
            rng.fill(&mut sk);
            sk
        })
        .finalize()[..32]
        .try_into()
        .unwrap();
let mut count: usize = 0;
let mut pk = ED25519_BASEPOINT_POINT.mul_clamped(expanded_sk);

loop {
    // foo(pk.compress().to_bytes());
    count += 1;
    pk += ED25519_BASEPOINT_POINT_MUL_BY_COFACTOR;
}
// expanded_sk += 8 * count;

The performance improved the generation by 3 orders of magnitude, so now the Edwards point compression is the only hot path now. Is it possible to do addition arithmetic on compressed Edwards point directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant