From b14430ecc83d91fcf9c8d5aee45cc2638c917988 Mon Sep 17 00:00:00 2001 From: Gregor Date: Thu, 7 Dec 2023 15:03:06 +0100 Subject: [PATCH] small fixes --- docs/zkapps/o1js/foreign-fields.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/zkapps/o1js/foreign-fields.mdx b/docs/zkapps/o1js/foreign-fields.mdx index a2700f8dc..aeeebf208 100644 --- a/docs/zkapps/o1js/foreign-fields.mdx +++ b/docs/zkapps/o1js/foreign-fields.mdx @@ -1,5 +1,5 @@ --- -title: Foreign Field Arthmetic +title: Foreign Field Arithmetic hide_title: true description: Foreign field arithmetic in o1js. keywords: @@ -20,7 +20,7 @@ Please note that zkApp programmability is not yet available on Mina Mainnet, but A foreign field is a [finite field](https://en.wikipedia.org/wiki/Modular_arithmetic) different from the native field of the proof system. o1js exposes operations like modular addition and multiplication that work in any finite field of size less than 2^259. -Foreign fields are useful for implementing cryptographic algorithms in provable code. For example, you use them for verification of Ethereum-compatible ECDSA signatures ([coming](https://github.com/o1-labs/o1js/pull/1240) [soon](https://github.com/o1-labs/o1js/pull/1291)). +Foreign fields are useful for implementing cryptographic algorithms in provable code. For example, you use them for verification of Ethereum-compatible ECDSA signatures ([coming](https://github.com/o1-labs/o1js/pull/1007) [soon](https://github.com/o1-labs/o1js/pull/1291)). ## Why foreign fields? @@ -28,7 +28,7 @@ If you already know what you need foreign fields for, you can skip this section. For additional context, recall that the core data type in o1js is `Field`. It represents the field that is _native to the proof system_. In other words, addition and multiplication of `Field`s are the fundamental operations upon which all provable code is built. Because a lot of cryptography uses finite fields, o1js supports several crypto algorithms natively, with high efficiency. See classes and modules like [Poseidon](../o1js-reference/modules#poseidon), [PublicKey](../o1js-reference/classes/Types.PublicKey), [PrivateKey](../o1js-reference/classes/PrivateKey), [Signature](../o1js-reference/classes/Signature) and [Encryption](../o1js-reference/modules/Encryption). -However, none of these are compatible with the cryptography typically used in the wider world: `Signature.verify()` doesn't let you verify a signed JWT or e-mail, and `Encryption.decrypt()` won't help you with your WhatsApp messages. That's because these use different finite fields than our native `Field` (which was chosen primarily to enable efficient zk proofs). +However, none of these are compatible with the cryptography used in the wider world: `Signature.verify()` doesn't let you verify a signed JWT or e-mail, and `Encryption.decrypt()` won't help you with your WhatsApp messages. That's because these use different finite fields than our native `Field` (which was chosen primarily to enable efficient zk proofs). Here is where foreign fields come in: They let you perform algorithms that connect your zkApp with the outside world of cryptography. Foreign fields come with an efficiency hit compared to the native field, but we heavily engineered them to be efficient enough to unlock many interesting use cases. @@ -78,14 +78,14 @@ let zero: ForeignField = Field17.from(0); let alsoZero: ForeignField = UInt256.from(0); ``` -`ForeignField` supports all the basic arithmetic operations: +`ForeignField` supports the basic arithmetic operations: ```ts x.add(x); // addition x.sub(2); // subtraction x.neg(); // negation -x.mul(x); // multiplication -x.div(3); // division +x.mul(3); // multiplication +x.div(x); // division x.inv(); // inverse ``` @@ -101,7 +101,7 @@ let bits = x.toBits(); // convert to a `Bool` array of size log2(modulus); Field17.fromBits(bits); // convert back ``` -And non-provable methods for converting to and from JS values: +And there are non-provable methods for converting to and from JS values: ```ts let y = SmallField.from(5n); // convert from bigint or number