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

feat(bb.js): initial API #232

Merged
merged 6 commits into from
Mar 14, 2023
Merged

feat(bb.js): initial API #232

merged 6 commits into from
Mar 14, 2023

Conversation

ludamad
Copy link
Collaborator

@ludamad ludamad commented Mar 9, 2023

Description

Barretenberg.js initial bindings. Mainly exposes pedersen. To make this work you should also merge adam/feat/typescript-bindings-yalc into the repo. It is not included here as it is many files that would distract the review. They should probably be merged together.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • There are no circuit changes, OR specifications in /markdown/specs have been updated.
  • There are no circuit changes, OR a cryptographer has been assigned for review.
  • I've updated any terraform that needs updating (e.g. environment variables) for deployment.
  • The branch has been rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.
  • New functions, classes, etc. have been documented according to the doxygen comment format. Classes and structs must have @brief describing the intended functionality.
  • If existing code has been modified, such documentation has been added or updated.

@ludamad ludamad force-pushed the adam/feat/typescript-bindings branch from 9ea1a07 to 754781a Compare March 9, 2023 19:18
@ludamad ludamad force-pushed the adam/feat/typescript-bindings branch from 754781a to db55a4c Compare March 10, 2023 15:05
@ludamad ludamad changed the base branch from aztec3 to master March 10, 2023 15:07
@ludamad ludamad changed the title Adam/feat/typescript bindings feat(bb.js): initial API Mar 10, 2023
"solidity.compileUsingRemoteVersion": "v0.6.10+commit.00c0fcaf",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settings for tsdk (at least if we decided to keep using PNP), prettier, eslint

$<TARGET_OBJECTS:stdlib_primitives_objects>
$<TARGET_OBJECTS:stdlib_schnorr_objects>
$<TARGET_OBJECTS:stdlib_pedersen_objects>
$<TARGET_OBJECTS:stdlib_blake2s_objects>
$<TARGET_OBJECTS:stdlib_blake3s_objects>
$<TARGET_OBJECTS:stdlib_sha256_objects>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing from wasm build

#!/usr/bin/env node
/* eslint-disable */
"use strict";

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PNP boilerplate

// If not done already, precompute constants.
wasm.call("pedersen__init");
const inputVectors = serializeBufferArrayToVector(inputs);
wasm.writeMemory(inputVectors, 0);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Should we be writing to 0 instead of using bbmalloc?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For data we can't control how big it will be should be written to allocated memory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought too. I did a straight refactor for now, but some stuff has overflow risks

* @param rhs - The second hash.
* @returns The new 32-byte hash.
*/
export function pedersenCompress(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the function format a lot for these wasm calls

* feat(b.js): bundle yalc dependencies

* doc: running instructions in README

---------

Co-authored-by: Adam Domurad <adam@aztecprotocol.com>
@PhilWindle PhilWindle marked this pull request as ready for review March 14, 2023 13:42
@PhilWindle PhilWindle merged commit c860b02 into master Mar 14, 2023
@PhilWindle PhilWindle deleted the adam/feat/typescript-bindings branch March 14, 2023 14:33
ludamad added a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 22, 2023
* fix: wasm build

* feat: vscode settings

* feat(b.js): initial typescript bindings

* doc: running instructions in README

* build: fix lint

* Adam/feat/typescript bindings yalc (AztecProtocol/barretenberg#241)

* feat(b.js): bundle yalc dependencies

* doc: running instructions in README

---------

Co-authored-by: Adam Domurad <adam@aztecprotocol.com>

---------

Co-authored-by: Adam Domurad <adam@aztecprotocol.com>
ludamad added a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 24, 2023
* fix: wasm build

* feat: vscode settings

* feat(b.js): initial typescript bindings

* doc: running instructions in README

* build: fix lint

* Adam/feat/typescript bindings yalc (AztecProtocol/barretenberg#241)

* feat(b.js): bundle yalc dependencies

* doc: running instructions in README

---------

Co-authored-by: Adam Domurad <adam@aztecprotocol.com>

---------

Co-authored-by: Adam Domurad <adam@aztecprotocol.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants