Skip to content

feat(bb.js): initial API#232

Merged
PhilWindle merged 6 commits into
masterfrom
adam/feat/typescript-bindings
Mar 14, 2023
Merged

feat(bb.js): initial API#232
PhilWindle merged 6 commits into
masterfrom
adam/feat/typescript-bindings

Conversation

@ludamad

@ludamad ludamad commented Mar 9, 2023

Copy link
Copy Markdown
Collaborator

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
Comment thread .vscode/settings.json
"solidity.compileUsingRemoteVersion": "v0.6.10+commit.00c0fcaf",
"search.exclude": {
"**/.yarn": true,
"**/.pnp.*": true

Copy link
Copy Markdown
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

Comment thread cpp/src/CMakeLists.txt
$<TARGET_OBJECTS:stdlib_pedersen_objects>
$<TARGET_OBJECTS:stdlib_blake2s_objects>
$<TARGET_OBJECTS:stdlib_blake3s_objects>
$<TARGET_OBJECTS:stdlib_sha256_objects>

Copy link
Copy Markdown
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

Comment thread ts/.pnp.cjs
#!/usr/bin/env node
/* eslint-disable */
"use strict";

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

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