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

Provable BigInt #2008

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d28f977
feat: bigint initial commit
boray Jan 31, 2025
9c8c858
refactor: factory pattern
boray Feb 6, 2025
8585388
Merge branch 'main' into feat/provable-bigint
boray Feb 6, 2025
a45cf07
fix: add, mul and others
boray Feb 9, 2025
e57e6c4
test: start from small prime field
boray Feb 9, 2025
f44eb20
test: fix minor issues and remove controversial cases
boray Feb 10, 2025
7a3fc1e
fix: wrap value with Unconstrained
boray Feb 10, 2025
f63a0c3
Merge branch 'main' into feat/provable-bigint
boray Feb 10, 2025
04acee9
chore: clean exports
boray Feb 10, 2025
8a236fb
Format files following provable-bigint changes
Shigoto-dev19 Feb 10, 2025
de8e0e0
Merge pull request #2022 from o1-labs/shigoto/provable-bigint-format
Shigoto-dev19 Feb 10, 2025
01839f9
Optimize bigint add method
Shigoto-dev19 Feb 10, 2025
2791036
Only return the remainder & Update tests and example code
Shigoto-dev19 Feb 11, 2025
f094edc
Optimize bigint sub method
Shigoto-dev19 Feb 11, 2025
a79fc3f
Fix the bigint div method
Shigoto-dev19 Feb 11, 2025
55d5f12
Fix JSDoc for the add method
Shigoto-dev19 Feb 11, 2025
4471c5a
Merge pull request #2024 from o1-labs/shigoto/provable-bigint-add: Op…
Shigoto-dev19 Feb 11, 2025
6e1c79a
Fix JSDoc for the sub method
Shigoto-dev19 Feb 11, 2025
543f243
Merge pull request #2025 from o1-labs/shigoto/provable-bigint-sub: Op…
Shigoto-dev19 Feb 11, 2025
422b119
fix: replace with generic rangecheck
boray Feb 11, 2025
5dada5f
Add bigint mod method
Shigoto-dev19 Feb 11, 2025
59b06a7
Fix the bigint div method
Shigoto-dev19 Feb 11, 2025
7d2ecd4
Add a new bigint double method
Shigoto-dev19 Feb 11, 2025
7eee4de
Merge pull request #2029 from o1-labs/shigoto/provable-bigint-double …
Shigoto-dev19 Feb 12, 2025
4cf2f13
Merge pull request #2028 from o1-labs/shigoto/provable-bigint-mod Add…
Shigoto-dev19 Feb 12, 2025
b6850de
Update JSDoc for the div method
Shigoto-dev19 Feb 12, 2025
8141a35
Merge branch 'shigoto/provable-bigint-div' of github.com:o1-labs/o1js…
Shigoto-dev19 Feb 12, 2025
4eec3ee
Add test case for division by zero
Shigoto-dev19 Feb 12, 2025
794b735
Merge branch 'feat/provable-bigint' into shigoto/provable-bigint-div
boray Feb 12, 2025
55758f5
Merge pull request #2027 from o1-labs/shigoto/provable-bigint-div Fix…
Shigoto-dev19 Feb 12, 2025
197354c
test: add BigInt381
boray Feb 13, 2025
3a66ae0
test: uncomment power and improvements
boray Feb 13, 2025
03cc10c
test: add randomized testing
boray Feb 13, 2025
91d4cfc
chore: update changelog
boray Feb 13, 2025
dc3ac6a
Merge branch 'main' into feat/provable-bigint
boray Feb 13, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- `MerkleList.popOption()` for popping the last element and also learning if there was one https://github.com/o1-labs/o1js/pull/1997
- Added custom header support for `Fetch` methods such as `fetchEvents`, `fetchActions` etc. and to `Mina` instance. Also added two new methods `setMinaDefaultHeaders` and `setArchiveDefaultHeaders` https://github.com/o1-labs/o1js/pull/2004
- Added style rules for contributors https://github.com/o1-labs/o1js/pull/2012
- **Provable BigInt** exposed through the `createProvableBigInt()` class factory https://github.com/o1-labs/o1js/pull/2008

### Changed

Expand Down
45 changes: 45 additions & 0 deletions src/examples/crypto/bigint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Experimental } from 'o1js';

const { ProvableBigInt, createProvableBigInt } = Experimental;

const BigInt384 = createProvableBigInt(97n);

let a = BigInt384.fromBigint(1n);
let b = BigInt384.fromBigint(2n);
let c = a.add(b);

console.log(a.toBigint());
console.log(b.toBigint());
console.log(c.toBigint());

a = BigInt384.fromBigint(71n);
b = BigInt384.fromBigint(31n);
c = a.sub(b);

console.log(a.toBigint());
console.log(b.toBigint());
console.log(c.toBigint());

a = BigInt384.fromBigint(3n);
b = BigInt384.fromBigint(2n);
c = a.mul(b);

console.log(a.toBigint());
console.log(b.toBigint());
console.log(c.toBigint());

a = BigInt384.fromBigint(6n);
b = BigInt384.fromBigint(2n);
c = a.mul(b);

console.log(a.toBigint());
console.log(b.toBigint());
console.log(c.toBigint());

a = BigInt384.fromBigint(1n);
b = BigInt384.fromBigint(2n);
c = a.sqrt();

console.log(a.toBigint());
console.log(b.toBigint());
console.log(c.toBigint());
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ import * as BatchReducer_ from './lib/mina/actions/batch-reducer.js';
import { Actionable } from './lib/mina/actions/offchain-state-serialization.js';
import { InferProvable } from './lib/provable/types/struct.js';
import { Recursive as Recursive_ } from './lib/proof-system/recursive.js';
import {
ProvableBigInt as ProvableBigInt_,
createProvableBigInt as createProvableBigInt_,
} from './lib/provable/bigint.js';
export { Experimental };

const Experimental_ = {
Expand All @@ -165,6 +169,9 @@ namespace Experimental {

export let Recursive = Recursive_;

export let ProvableBigInt = ProvableBigInt_;
export let createProvableBigInt = createProvableBigInt_;

// indexed merkle map
export let IndexedMerkleMap = Experimental_.IndexedMerkleMap;
export type IndexedMerkleMap = IndexedMerkleMapBase;
Expand Down
Loading
Loading