Skip to content

ed25519: add 128-bit NAF path#27

Open
efagerho wants to merge 1 commit into
anza-xyz:masterfrom
efagerho:naf-128
Open

ed25519: add 128-bit NAF path#27
efagerho wants to merge 1 commit into
anza-xyz:masterfrom
efagerho:naf-128

Conversation

@efagerho

@efagerho efagerho commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Add Scalar::non_adjacent_form_128 and use it in the serial and vector triple-base verifier paths for scalars known to fit in 128 bits. The helper computes only the HEEA-readable digit range instead of producing a full 256-entry NAF array for each scalar.

Benchmark notes:

  • Ran this repository's Criterion benchmark program, benches/bench.rs, filtering to Single Verification, pinned to CPU 4 with 1s warmup, 2s measurement, and sample size 10.

  • local_verify_zebra estimate was 19.740 us, with 95% CI 19.686..19.789 us.

  • master measured 20.051 us, with 95% CI 19.938..20.134 us, so this branch was about 1.55% faster in that run.

Add Scalar::non_adjacent_form_128 and use it in the serial and vector triple-base verifier paths for scalars known to fit in 128 bits. The helper computes only the HEEA-readable digit range instead of producing a full 256-entry NAF array for each scalar.

Benchmark notes:

- Ran this repository's Criterion benchmark program, benches/bench.rs, filtering to Single Verification, pinned to CPU 4 with 1s warmup, 2s measurement, and sample size 10.

- local_verify_zebra estimate was 19.740 us, with 95% CI 19.686..19.789 us.

- master measured 20.051 us, with 95% CI 19.938..20.134 us, so this branch was about 1.55% faster in that run.
@zz-sol zz-sol self-requested a review June 8, 2026 16:49
}

/// Compute a width-\\(w\\) non-adjacent form for scalars known to fit in 128 bits.
pub(crate) fn non_adjacent_form_128(&self, w: usize) -> [i8; NAF_128_SIZE] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it possible to merge this function with non_adjacent_form to avoid duplicated code? For example,

fn non_adjacent_form(&self, w: usize, bits: usize)

with bits = 256 or 128?

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

Successfully merging this pull request may close these issues.

2 participants