-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add UInt128 for u128 #21
Conversation
On the way of fixing multiple errors. May take a longer time. It seems that A separate implementation would be needed for |
Maybe you can use BigInteger256? |
Passing. But a code review is needed. This implementation uses |
I would merge this for now. But we likely need a revisit later (I will create an issue), very likely to replace with |
let b = AllocatedBit::new_witness(cs.clone(), || { | ||
result_value.map(|v| (v >> i) & 1 == 1).get() | ||
})?; | ||
let b = AllocatedBit::new_witness(cs.clone(), || result_value.clone().map(|v| (v >> i) & BigUint::one() == BigUint::one()).get())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can rewrite this more simply as
let b = AllocatedBit::new_witness(cs.clone(), || result_value.as_ref().map(|v| (v >> i) == BigUint::one()).get())?;
@@ -246,7 +251,12 @@ macro_rules! make_uint { | |||
} | |||
|
|||
// The value of the actual result is modulo 2^$size | |||
let modular_value = result_value.map(|v| v as $native); | |||
let modular_value = result_value.clone().map(|v| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can avoid the clone here by doing as_ref()
instead
let modular_value = result_value.map(|v| v as $native); | ||
let modular_value = result_value.clone().map(|v| | ||
{ | ||
let modulus = BigUint::from(1u64) << ($size as u32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BigUint::from(1u64)
-> BigUint::one()
.
Sorry this review is kinda late lol |
No description provided.