Skip to content

Commit

Permalink
Test embedded curve ops
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Nov 21, 2024
1 parent d89d68d commit ac90774
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test_programs/noir_test_success/comptime_blackbox/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Tests to show that the comptime interpreter implement blackbox functions.
use std::bigint;
use std::embedded_curve_ops::{EmbeddedCurvePoint, EmbeddedCurveScalar, multi_scalar_mul};

/// Test that all bigint operations work in comptime.
#[test]
Expand Down Expand Up @@ -106,6 +107,19 @@ fn test_sha256() {
assert_eq(hash[31], 0x2b);
}

/// Test that `embedded_curve_add` and `multi_scalar_mul` are implemented.
#[test]
fn test_embedded_curve_ops() {
let (sum, mul) = comptime {
let g1 = EmbeddedCurvePoint { x: 1, y: 17631683881184975370165255887551781615748388533673675138860, is_infinite: false };
let s1 = EmbeddedCurveScalar { lo: 1, hi: 0 };
let sum = g1 + g1;
let mul = multi_scalar_mul([g1, g1], [s1, s1]);
(sum, mul)
};
assert_eq(sum, mul);
}

/// Parse a lowercase hexadecimal string (without 0x prefix) as byte slice.
comptime fn hex_to_bytes<let N: u32>(s: str<N>) -> [u8] {
assert(N % 2 == 0);
Expand Down

0 comments on commit ac90774

Please sign in to comment.