-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Point::fromXandSign(...) (#7455)
- Loading branch information
Showing
6 changed files
with
189 additions
and
4 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
barretenberg/cpp/src/barretenberg/ecc/curves/bn254/c_bind.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "../bn254/fr.hpp" | ||
#include "barretenberg/common/wasm_export.hpp" | ||
|
||
using namespace bb; | ||
|
||
WASM_EXPORT void bn254_fr_sqrt(uint8_t const* input, uint8_t* result) | ||
{ | ||
using serialize::write; | ||
auto input_fr = from_buffer<bb::fr>(input); | ||
auto [is_sqr, root] = input_fr.sqrt(); | ||
|
||
uint8_t* is_sqrt_result_ptr = result; | ||
uint8_t* root_result_ptr = result + 1; | ||
|
||
write(is_sqrt_result_ptr, is_sqr); | ||
write(root_result_ptr, root); | ||
} | ||
|
||
// NOLINTEND(cert-dcl37-c, cert-dcl51-cpp, bugprone-reserved-identifier) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Fr } from './fields.js'; | ||
import { Point } from './point.js'; | ||
|
||
describe('Point', () => { | ||
it('converts to and from x and sign of y coordinate', () => { | ||
const p = new Point( | ||
new Fr(0x30426e64aee30e998c13c8ceecda3a77807dbead52bc2f3bf0eae851b4b710c1n), | ||
new Fr(0x113156a068f603023240c96b4da5474667db3b8711c521c748212a15bc034ea6n), | ||
false, | ||
); | ||
|
||
const [x, sign] = p.toXAndSign(); | ||
const p2 = Point.fromXAndSign(x, sign); | ||
|
||
expect(p.equals(p2)).toBeTruthy(); | ||
}); | ||
|
||
it('creates a valid random point', () => { | ||
expect(Point.random().isOnGrumpkin()).toBeTruthy(); | ||
}); | ||
|
||
it('converts to and from buffer', () => { | ||
const p = Point.random(); | ||
const p2 = Point.fromBuffer(p.toBuffer()); | ||
|
||
expect(p.equals(p2)).toBeTruthy(); | ||
}); | ||
|
||
it('converts to and from compressed buffer', () => { | ||
const p = Point.random(); | ||
const p2 = Point.fromCompressedBuffer(p.toCompressedBuffer()); | ||
|
||
expect(p.equals(p2)).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
225c6f6
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.
Possible performance regression was detected for benchmark 'C++ Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.Goblin::merge(t)
208096682
ns/iter197048349
ns/iter1.06
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ludamad @codygunton