Comments (9)
Great! I'll try to make suggestion for the remaining rest.
Meanwhile I've added exports for sqrt and inversions for fp and fp2. Just in case for reference, difference between eucl_inverse and inverse is constant-time-ness.
from blstrs.
As a follow-up to last note in previous message. This
should rather use blst_uint64_from_fp.
from blstrs.
Speaking of blst_fp used in FpRepr. I oppose the idea of reusing blst_fp for FpRepr, because it gives misleading impression. General idea is that application should abstain from making specific assumptions about internals of blst types. The fact that they are expressed as collection of 6-element array of 64-bit values is rather for memory management purposes than for application to dig into. For now it works because both supported platforms are 64-bit ones, but it should be viewed as circumstantial.
To elaborate further. Ultimate idea is to have application treat blst data as opaque. Imagine a platform with hw-assisted 512-bit multiplier emerging. It might mean that storage for field elements would have to be increased, but even if not, it would definitely have effect on Montgomery representation. And at the same time it would be desired that application code wouldn't have to be modified, it should be sufficient to compile it for another target. Yes, it means that application shouldn't have constants in Montgomery representation and pass them directly to blst. Even though it can now, it's appropriate to work toward omitting them from the start. Two options.
-
Have application keep constants in non-Montgomery representation and use suitable
blst_fp_from_*
. (It's shame that Rust doesn't have constant constructors, so that constants could be instantiated in more uniform manner.) -
Add blst interface that would convert between "natural" Montgomery representation and internal blst representation for application to instantiate Montgomery constants. For now it would be just equivalent of memcpy, which might feel silly, but it will serve the greater purpose.
Formally speaking these are not mutually exclusive, but in either case application should not pass constants to blst verbatim.
from blstrs.
I have switched FpRepr
to use [u64; 6]
directly and updated the u64 conversions as described by you here: 108181c
from blstrs.
(It's shame that Rust doesn't have constant constructors, so that constants could be instantiated in more uniform manner.)
You can have constant constructors, just not using ffi calls
const FOO1: Foo = Foo::new(1);
struct Foo(u32)
impl Foo {
pub const fn new(val: u32) -> Self {
Foo(val)
}
}
works fine
from blstrs.
* Add blst interface that would convert between "natural" Montgomery representation and internal blst representation for application to instantiate Montgomery constants. For now it would be just equivalent of memcpy, which might feel silly, but it will serve the greater purpose.
This would be really nice to have, especially for testing.
from blstrs.
(It's shame that Rust doesn't have constant constructors, so that constants could be instantiated in more uniform manner.)
You can have constant constructors, just not using ffi calls
My understanding is that you can't call a function, i.e. it has lesser to do with ffi. Well, it appears that you can call const fn
but it's limited by its constant-ness. And I naturally meant constant constructors that wouldn't be as constrained, implying that blst_fp constants would be initialized with calls to Montgomery conversion (of either kind) prior application code executes.
This [conversion between 6-limb "natural" Montgomery representation and blst_fp] would be really nice to have, especially for testing.
OK...
from blstrs.
Except for some tests and constants, the reprs and conversions are now all using the transformation methods and not the internal representation anymore.
from blstrs.
should all be fixed now
from blstrs.
Related Issues (20)
- scalar.rs HOT 9
- Pairing Issue HOT 2
- Optional adx feature support? HOT 3
- Merge 0-1 branch into master
- multi-exponentiation HOT 7
- Add x86 support for blstrs HOT 5
- s390x support for blstrs HOT 3
- serde? HOT 1
- Investigate improvements for 32bit/64bit code
- Fp::from_bytes_le HOT 1
- Fixed blst version HOT 10
- Support of hash_to_curve using blst_map_to_g1/g2 HOT 1
- The problem of subtraction on bls12-382
- impl Ord for Fp2 HOT 2
- The problem of subtracting points on bls12-381.
- Questions about the point represented by "G1_affine"?
- random in g1.rs HOT 1
- is_zero is g1.c HOT 5
- double in g1.rs HOT 1
- Should Fp6 be part of the public API? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blstrs.