-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stdlib): grumpkin scalar multiplication API (#2586)
Co-authored-by: kevaundray <[email protected]>
- Loading branch information
1 parent
2d0a5e4
commit dc34bc4
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
struct GrumpkinScalar { | ||
low: Field, | ||
high: Field, | ||
} | ||
|
||
impl GrumpkinScalar { | ||
fn new(low: Field, high: Field) -> Self { | ||
// TODO: check that the low and high value fit within the grumpkin modulus | ||
GrumpkinScalar { low, high } | ||
} | ||
} | ||
|
||
global GRUMPKIN_SCALAR_SERIALISED_LEN: Field = 2; | ||
|
||
fn deserialise_grumpkin_scalar(fields: [Field; GRUMPKIN_SCALAR_SERIALISED_LEN]) -> GrumpkinScalar { | ||
GrumpkinScalar { low: fields[0], high: fields[1] } | ||
} | ||
|
||
fn serialise_grumpkin_scalar(scalar: GrumpkinScalar) -> [Field; GRUMPKIN_SCALAR_SERIALISED_LEN] { | ||
[scalar.low, scalar.high] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use crate::grumpkin_scalar::GrumpkinScalar; | ||
use crate::scalar_mul::fixed_base_embedded_curve; | ||
|
||
fn grumpkin_fixed_base(scalar: GrumpkinScalar) -> [Field; 2] { | ||
// TODO: this should use both the low and high limbs to do the scalar multiplication | ||
fixed_base_embedded_curve(scalar.low) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters