Skip to content

Commit

Permalink
Merge pull request #393 from o1-labs/rename-circuit
Browse files Browse the repository at this point in the history
rename circuit to provable
  • Loading branch information
barriebyron authored Jul 12, 2023
2 parents 86d838b + a64fd2c commit 1e14fb3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/zkapps/snarkyjs/smart-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Therefore, when executing your code and trying to read the value of `x` to turn
This is why we have a special function for logging stuff from inside your method:

```ts
Circuit.log(x);
Provable.log(x);
```

The API is like that of `console.log`, but it will automatically handle printing SnarkyJS data types in a nice format. During SmartContract compilation, it will simply do nothing.
Expand Down
12 changes: 6 additions & 6 deletions docs/zkapps/tutorials/05-common-types-and-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ points8 Fields: {"points":[{"x":"0","y":"0"},{"x":"1","y":"10"},{"x":"2","y":"20

There are two functions which help do control flow within SnarkyJS:

- [Circuit.if](../snarkyjs-reference/classes/Circuit#if)
- [Circuit.switch](../snarkyjs-reference/classes/Circuit#switch)
- [Provable.if](../snarkyjs-reference/classes/Circuit#if)
- [Provable.switch](../snarkyjs-reference/classes/Circuit#switch)

`Circuit.if` is similar to a ternary in JavaScript. `Circuit.switch` is similar to a switch case statement in JavaScript.
`Provable.if` is similar to a ternary in JavaScript. `Provable.switch` is similar to a switch case statement in JavaScript.

With these, you can write conditionals inside SnarkyJS.

Expand All @@ -220,7 +220,7 @@ const input2 = Int64.from(-15);

const inputSum = input1.add(input2);

const inputSumAbs = Circuit.if(
const inputSumAbs = Provable.if(
inputSum.isPositive(),
inputSum,
inputSum.mul(Int64.minusOne)
Expand All @@ -244,7 +244,7 @@ const input3largest = input3
.isPositive()
.and(input3.sub(input2).isPositive());

const largest = Circuit.switch(
const largest = Provable.switch(
[input1largest, input2largest, input3largest],
Int64,
[input1, input2, input3]
Expand All @@ -261,7 +261,7 @@ inputSumAbs: 5
largest: 22
```

Note that when using `Circuit.if`, like in a JS ternary, both branches are executed. Unlike normal programming, because SnarkyJS under the hood is creating a zk circuit, there is no primitive for if statements where only one branch is executed.
Note that when using `Provable.if`, like in a JS ternary, both branches are executed. Unlike normal programming, because SnarkyJS under the hood is creating a zk circuit, there is no primitive for if statements where only one branch is executed.

## Assertions and Constraints

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Poseidon,
PublicKey,
Signature,
Circuit,
Provable,
} from 'snarkyjs';

class MerkleWitness20 extends MerkleWitness(20) {}
Expand Down Expand Up @@ -59,7 +59,7 @@ export class LedgerContract extends SmartContract {
const recipientAccountNew = rootSenderAfter.equals(rootRecipientBeforeEmpty);

// check requirements on the recipient state before receiving
const recipientAccountPassesRequirements = Circuit.if(
const recipientAccountPassesRequirements = Provable.if(
recipientAccountNew,
(() => {
// new account
Expand Down
6 changes: 3 additions & 3 deletions examples/zkapps/05-common-types-and-functions/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Signature,
Poseidon,
Field,
Circuit,
Provable,
MerkleWitness,
MerkleTree,
AccountUpdate,
Expand Down Expand Up @@ -121,7 +121,7 @@ const input2 = Int64.from(-15);

const inputSum = input1.add(input2);

const inputSumAbs = Circuit.if(
const inputSumAbs = Provable.if(
inputSum.isPositive(),
inputSum,
inputSum.mul(Int64.minusOne)
Expand All @@ -145,7 +145,7 @@ const input3largest = input3
.isPositive()
.and(input3.sub(input2).isPositive());

const largest = Circuit.switch(
const largest = Provable.switch(
[input1largest, input2largest, input3largest],
Int64,
[input1, input2, input3]
Expand Down

1 comment on commit 1e14fb3

@vercel
Copy link

@vercel vercel bot commented on 1e14fb3 Jul 12, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

docs2 – ./

docs.minaprotocol.com
docs2-git-main-minadocs.vercel.app
docs2-minadocs.vercel.app

Please sign in to comment.