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

fix: bigint builtins are foreigns #6892

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::rc::Rc;

use acvm::{acir::BlackBoxFunc, AcirField, FieldElement};
use acvm::{AcirField, FieldElement};
use builtin_helpers::{
block_expression_to_value, byte_array_type, check_argument_count,
check_function_not_yet_resolved, check_one_argument, check_three_arguments,
Expand Down Expand Up @@ -236,9 +236,6 @@ impl<'local, 'context> Interpreter<'local, 'context> {
"unresolved_type_is_field" => unresolved_type_is_field(interner, arguments, location),
"unresolved_type_is_unit" => unresolved_type_is_unit(interner, arguments, location),
"zeroed" => zeroed(return_type, location.span),
blackbox if BlackBoxFunc::is_valid_black_box_func_name(blackbox) => {
self.call_foreign(blackbox, arguments, return_type, location)
}
_ => {
let item = format!("Comptime evaluation for builtin function '{name}'");
Err(InterpreterError::Unimplemented { item, location })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ let vec: BoundedVec<u32, 4> = BoundedVec::from_parts([1, 2, 3, 0], 3);
assert_eq(vec.len(), 3);

// Any elements past the given length are zeroed out, so these
// two BoundedVecs will be completely equal
// two vectors will be completely equal
let vec1: BoundedVec<u32, 4> = BoundedVec::from_parts([1, 2, 3, 1], 3);
let vec2: BoundedVec<u32, 4> = BoundedVec::from_parts([1, 2, 3, 2], 3);
assert_eq(vec1, vec2);
Expand Down Expand Up @@ -433,7 +433,7 @@ let vec: BoundedVec<u32, 4> = BoundedVec::from_parts_unchecked([1, 2, 3, 0], 3);
let vec1: BoundedVec<u32, 4> = BoundedVec::from_parts_unchecked([1, 2, 3, 1], 3);
let vec2: BoundedVec<u32, 4> = BoundedVec::from_parts_unchecked([1, 2, 3, 2], 3);

// both vecs have length 3 so we'd expect them to be equal, but this
// both vectors have length 3 so we'd expect them to be equal, but this
// fails because elements past the length are still checked in eq
assert(vec1 != vec2);
```
Expand Down
12 changes: 6 additions & 6 deletions noir_stdlib/src/bigint.nr
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ pub struct BigInt {
// docs:end:big_int_definition

impl BigInt {
#[builtin(bigint_add)]
#[foreign(bigint_add)]
fn bigint_add(self, other: BigInt) -> BigInt {}
#[builtin(bigint_sub)]
#[foreign(bigint_sub)]
fn bigint_sub(self, other: BigInt) -> BigInt {}
#[builtin(bigint_mul)]
#[foreign(bigint_mul)]
fn bigint_mul(self, other: BigInt) -> BigInt {}
#[builtin(bigint_div)]
#[foreign(bigint_div)]
fn bigint_div(self, other: BigInt) -> BigInt {}
#[builtin(bigint_from_le_bytes)]
#[foreign(bigint_from_le_bytes)]
fn from_le_bytes(bytes: [u8], modulus: [u8]) -> BigInt {}
#[builtin(bigint_to_le_bytes)]
#[foreign(bigint_to_le_bytes)]
fn to_le_bytes(self) -> [u8; 32] {}

fn check_32_bytes(self: Self, other: BigInt) -> bool {
Expand Down
Loading