Skip to content

Commit

Permalink
Fixing many typos (risc0#1683)
Browse files Browse the repository at this point in the history
Supersedes risc0#1319

---------

Co-authored-by: weikengchen <[email protected]>
  • Loading branch information
flaub and weikengchen authored Apr 18, 2024
1 parent 2fb409b commit 461c57b
Show file tree
Hide file tree
Showing 55 changed files with 137 additions and 135 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/bench_pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Benchmark Check

on:
push:
branches: [main, "release-*"]
pull_request:
branches: [main, "release-*"]
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion examples/sha/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use sha_methods::{HASH_ELF, HASH_ID, HASH_RUST_CRYPTO_ELF};
/// HASH_ELF uses the risc0_zkvm::sha interface for hashing.
/// HASH_RUST_CRYPTO_ELF uses RustCrypto's [sha2] crate, patched to use the RISC
/// Zero accelerator. See `src/methods/guest/Cargo.toml` for the patch
/// definition, which can be used to enable SHA-256 accelerrator support
/// definition, which can be used to enable SHA-256 accelerator support
/// everywhere the [sha2] crate is used.
fn provably_hash(input: &str, use_rust_crypto: bool) -> (Digest, Receipt) {
let env = ExecutorEnv::builder()
Expand Down
2 changes: 1 addition & 1 deletion examples/smartcore-ml/methods/guest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
let is_svm: bool = env::read();

if !is_svm {
// Read the model from the host into a SmartCore Decesion Tree model object.
// Read the model from the host into a SmartCore Decision Tree model object.
// We MUST explicitly declare the correct type in order for deserialization to be
// successful.
type Model = DecisionTreeClassifier<f64, u32, DenseMatrix<f64>, Vec<u32>>;
Expand Down
6 changes: 3 additions & 3 deletions examples/smartcore-ml/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn predict() -> Vec<u32> {
// ```
let prover = default_prover();

// This initiates a session, runs the STARK prover on the resulting exection
// This initiates a session, runs the STARK prover on the resulting execution
// trace, and produces a receipt.
let receipt = prover.prove(env, ML_TEMPLATE_ELF).unwrap().receipt;

Expand Down Expand Up @@ -131,7 +131,7 @@ mod test {
];

// We create the SVC params and train the SVC model.
// The paramaters will NOT get serialized due to a serde_skip command in the
// The parameters will NOT get serialized due to a serde_skip command in the
// source code for the SVC struct.
let knl = Kernels::linear();
let params = &SVCParameters::default().with_c(200.0).with_kernel(knl);
Expand All @@ -156,7 +156,7 @@ mod test {
let exec = default_executor();
let session = exec.execute(env, ML_TEMPLATE_ELF).unwrap();

// We read the result commited to the journal by the guest code.
// We read the result committed to the journal by the guest code.
let result: Vec<f64> = session.journal.decode().unwrap();

let y_expected: Vec<f64> = vec![
Expand Down
2 changes: 1 addition & 1 deletion examples/waldo/core/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod zkvm {
/// chunk coordinates.
fn get_chunk(&self, x: u32, y: u32) -> &RgbImage {
// Check that the given x if within the bounds of the width. No need to check y
// since if y is out of bounds the VectorOrcacle query will be out
// since if y is out of bounds the VectorOracle query will be out
// of bounds.
match self.cache.get(&(x, y)) {
Some(chunk) => chunk,
Expand Down
4 changes: 2 additions & 2 deletions examples/waldo/core/src/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub type Node = Digest;
///
/// MerkleTree is a wrapper around the `merkle_light::merkle::MerkleTree`,
/// created to integrate with the RISC0 SHA256 coprocessor, functionality to act
/// as a vector oracle for the for the guest, and some convinience functions.
/// as a vector oracle for the for the guest, and some convenient functions.
pub struct MerkleTree<Element>
where
Element: Hashable<ShaHasher>,
Expand Down Expand Up @@ -352,7 +352,7 @@ mod test {

#[test]
fn algorithm_is_consistent_with_sha2() {
let test_string: &'static [u8] = "RISCO SHA hasher test string".as_bytes();
let test_string: &'static [u8] = "RISC0 SHA hasher test string".as_bytes();
let mut hasher = ShaHasher::default();
hasher.write(test_string);
let node = hasher.hash();
Expand Down
2 changes: 1 addition & 1 deletion examples/xgboost/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XGBoost example

This example is meant to serve a guide for developers interested in using the RISC Zero for zkML applications using the popular XGBoost machine learning model. The model can be trained in Python and exported as a JSON file to into the RISC Zero zkVM. Inference is computed within the guest code, allowing developers to submit a cryptoraphic receipt attesting to the correct execution of the trained model without revealing either the inputs or the model parameters.
This example is meant to serve a guide for developers interested in using the RISC Zero for zkML applications using the popular XGBoost machine learning model. The model can be trained in Python and exported as a JSON file to into the RISC Zero zkVM. Inference is computed within the guest code, allowing developers to submit a cryptographic receipt attesting to the correct execution of the trained model without revealing either the inputs or the model parameters.

Model training takes place in a Python Jupyter Notebook using the XGBoost model from the Forust machine learning package. The package is a pure Rust implementation of the XGBoost algorithm, complete with Python bindings. This allowing developers to focus on data collection, feature engineering, and other machine learning related pre-processing tasks using all of the tools available in the Python machine learning ecosystem.

Expand Down
2 changes: 1 addition & 1 deletion examples/xgboost/methods/guest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ fn main() {
// write public output to the journal
env::commit(&answer);

// If you want to obtain total cycle count to bechnmark performance, you can use the code below.
// If you want to obtain total cycle count to benchmark performance, you can use the code below.
println!("cycles: {}", env::cycle_count());
}
4 changes: 2 additions & 2 deletions examples/xgboost/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ fn predict() -> f64 {
// We serialize the model to a byte array before transferring it to the guest.
let model_bytes: Vec<u8> = rmp_serde::to_vec(&model).unwrap();

// We define an input value for the model (inputs are block number and numbe of transaction in that block. Note we modify the block number to a f64 value).
// We define an input value for the model (inputs are block number and number of transaction in that block. Note we modify the block number to a f64 value).
//**************************//
// ADD YOUR INPUT DATA HERE //
//**************************//
let data: Vec<f64> = vec![18511304.0, 117.0];

// We transfer theinput data, the rmp array length, and the serialized model over to the guest.
// We transfer the input data, the rmp array length, and the serialized model over to the guest.
let env = ExecutorEnv::builder()
.write(&data)
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions risc0/binfmt/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<T: Digestible> Digestible for Option<T> {
}
}

/// A struct hashing routine, permiting tree-like opening of fields.
/// A struct hashing routine, permitting tree-like opening of fields.
///
/// Used for hashing of the receipt claim, and in the recursion predicates.
pub fn tagged_struct<S: Sha256>(tag: &str, down: &[impl Borrow<Digest>], data: &[u32]) -> Digest {
Expand All @@ -67,7 +67,7 @@ pub fn tagged_struct<S: Sha256>(tag: &str, down: &[impl Borrow<Digest>], data: &
*S::hash_bytes(&all)
}

/// A list hashing routine, permiting iterative opening over elements.
/// A list hashing routine, permitting iterative opening over elements.
///
/// Used for hashing of the receipt claim assumptions list, and in the recursion
/// predicates.
Expand Down
2 changes: 1 addition & 1 deletion risc0/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ pub fn embed_methods_with_options(
.unwrap();

// HACK: It's not particularly practical to figure out all the
// files that all the guest crates transtively depend on. So, we
// files that all the guest crates transitively depend on. So, we
// want to run the guest "cargo build" command each time we build.
//
// Since we generate methods.rs each time we run, it will always
Expand Down
10 changes: 5 additions & 5 deletions risc0/build_kernel/kernels/cuda/fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
/// - Otherwise have as large a power of 2 in the factors of P-1 as possible.
///
/// This last property is useful for number theoretical transforms (the fast fourier transform
/// equivelant on finite fields). See NTT.h for details.
/// equivalent on finite fields). See NTT.h for details.
///
/// The Fp class wraps all the standard arithmatic operations to make the finite field elements look
/// The Fp class wraps all the standard arithmetic operations to make the finite field elements look
/// basically like ordinary numbers (which they mostly are).
class Fp {
public:
Expand Down Expand Up @@ -78,7 +78,7 @@ class Fp {

static __device__ constexpr uint32_t decode(uint32_t a) { return mul(1, a); }

// A private constructor that take the 'interal' form.
// A private constructor that take the 'internal' form.
__device__ constexpr Fp(uint32_t val, bool ignore) : val(val) {}

public:
Expand Down Expand Up @@ -180,9 +180,9 @@ __device__ constexpr inline Fp pow(Fp x, size_t n) {
}

/// Compute the multiplicative inverse of x, or `1/x` in finite field terms. Since `x^(P-1) == 1
/// (mod P)` for any x != 0 (as a consequence of Fermat's little therorm), it follows that `x *
/// (mod P)` for any x != 0 (as a consequence of Fermat's little theorem), it follows that `x *
/// x^(P-2) == 1 (mod P)` for x != 0. That is, `x^(P-2)` is the multiplicative inverse of x.
/// Computed this way, the 'inverse' of zero comes out as zero, which is convient in many cases, so
/// Computed this way, the 'inverse' of zero comes out as zero, which is convenient in many cases, so
/// we leave it.
__device__ constexpr inline Fp inv(Fp x) {
return pow(x, Fp::P - 2);
Expand Down
20 changes: 10 additions & 10 deletions risc0/build_kernel/kernels/cuda/fpext.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma once

/// \file
/// Defines FpExt, a finite field F_p^4, based on Fp via the irreducable polynomial x^4 - 11.
/// Defines FpExt, a finite field F_p^4, based on Fp via the irreducible polynomial x^4 - 11.

#include "fp.h"

Expand All @@ -24,12 +24,12 @@
#define BETA Fp(11)
#define NBETA Fp(Fp::P - 11)

/// Intstances of FpExt are element of a finite field F_p^4. They are represented as elements of
/// Instances of FpExt are element of a finite field F_p^4. They are represented as elements of
/// F_p[X] / (X^4 - 11). Basically, this is a 'big' finite field (about 2^128 elements), which is
/// used when the security of various operations depends on the size of the field. It has the field
/// Fp as a subfield, which means operations by the two are compatable, which is important. The
/// irreducible polynomial was choosen to be the simpilest possible one, x^4 - B, where 11 is the
/// smallest B which makes the polynomial irreducable.
/// Fp as a subfield, which means operations by the two are compatible, which is important. The
/// irreducible polynomial was chosen to be the simplest possible one, x^4 - B, where 11 is the
/// smallest B which makes the polynomial irreducible.
struct FpExt {
/// The elements of FpExt, elems[0] + elems[1]*X + elems[2]*X^2 + elems[3]*x^4
Fp elems[4];
Expand Down Expand Up @@ -108,7 +108,7 @@ struct FpExt {
// Now we get to the interesting case of multiplication. Basically, multiply out the polynomial
// representations, and then reduce module x^4 - B, which means powers >= 4 get shifted back 4 and
// multiplied by -beta. We could write this as a double loops with some if's and hope it gets
// unrolled properly, but it'a small enough to just hand write.
// unrolled properly, but it's small enough to just hand write.
__device__ constexpr FpExt operator*(FpExt rhs) const {
// Rename the element arrays to something small for readability
#define a elems
Expand Down Expand Up @@ -161,18 +161,18 @@ __device__ constexpr inline FpExt pow(FpExt x, size_t n) {
/// Compute the multiplicative inverse of an FpExt.
__device__ constexpr inline FpExt inv(FpExt in) {
#define a in.elems
// Compute the multiplicative inverse by basicly looking at FpExt as a composite field and using
// Compute the multiplicative inverse by basically looking at FpExt as a composite field and using
// the same basic methods used to invert complex numbers. We imagine that initially we have a
// numerator of 1, and an denominator of a. i.e out = 1 / a; We set a' to be a with the first and
// third components negated. We then multiply the numerator and the denominator by a', producing
// out = a' / (a * a'). By construction (a * a') has 0's in it's first and third elements. We
// call this number, 'b' and compute it as follows.
Fp b0 = a[0] * a[0] + BETA * (a[1] * (a[3] + a[3]) - a[2] * a[2]);
Fp b2 = a[0] * (a[2] + a[2]) - a[1] * a[1] + BETA * (a[3] * a[3]);
// Now, we make b' by inverting b2. When we muliply both sizes by b', we get out = (a' * b') /
// (b * b'). But by construcion b * b' is in fact an element of Fp, call it c.
// Now, we make b' by inverting b2. When we multiply both sizes by b', we get out = (a' * b') /
// (b * b'). But by construction b * b' is in fact an element of Fp, call it c.
Fp c = b0 * b0 + BETA * b2 * b2;
// But we can now invert C direcly, and multiply by a'*b', out = a'*b'*inv(c)
// But we can now invert C directly, and multiply by a'*b', out = a'*b'*inv(c)
Fp ic = inv(c);
// Note: if c == 0 (really should only happen if in == 0), our 'safe' version of inverse results
// in ic == 0, and thus out = 0, so we have the same 'safe' behavior for FpExt. Oh, and since we
Expand Down
10 changes: 5 additions & 5 deletions risc0/build_kernel/kernels/metal/fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
/// - Otherwise have as large a power of 2 in the factors of P-1 as possible.
///
/// This last property is useful for number theoretical transforms (the fast fourier transform
/// equivelant on finite fields). See NTT.h for details.
/// equivalent on finite fields). See NTT.h for details.
///
/// The Fp class wraps all the standard arithmatic operations to make the finite field elements look
/// The Fp class wraps all the standard arithmetic operations to make the finite field elements look
/// basically like ordinary numbers (which they mostly are).
class Fp {
public:
Expand Down Expand Up @@ -77,7 +77,7 @@ class Fp {

static constexpr uint32_t decode(uint32_t a) { return mul(1, a); }

// A private constructor that take the 'interal' form.
// A private constructor that take the 'internal' form.
constexpr Fp(uint32_t val, bool ignore) : val(val) {}

public:
Expand Down Expand Up @@ -208,9 +208,9 @@ constexpr inline Fp pow(Fp x, size_t n) {
}

/// Compute the multiplicative inverse of x, or `1/x` in finite field terms. Since `x^(P-1) == 1
/// (mod P)` for any x != 0 (as a consequence of Fermat's little therorm), it follows that `x *
/// (mod P)` for any x != 0 (as a consequence of Fermat's little theorem), it follows that `x *
/// x^(P-2) == 1 (mod P)` for x != 0. That is, `x^(P-2)` is the multiplicative inverse of x.
/// Computed this way, the 'inverse' of zero comes out as zero, which is convient in many cases, so
/// Computed this way, the 'inverse' of zero comes out as zero, which is convenient in many cases, so
/// we leave it.
constexpr inline Fp inv(Fp x) {
return pow(x, Fp::P - 2);
Expand Down
20 changes: 10 additions & 10 deletions risc0/build_kernel/kernels/metal/fpext.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#pragma once

/// \file
/// Defines FpExt, a finite field F_p^4, based on Fp via the irreducable polynomial x^4 - 11.
/// Defines FpExt, a finite field F_p^4, based on Fp via the irreducible polynomial x^4 - 11.

#include <metal_stdlib>

Expand All @@ -26,12 +26,12 @@
#define BETA Fp(11)
#define NBETA Fp(Fp::P - 11)

/// Intstances of FpExt are element of a finite field F_p^4. They are represented as elements of
/// Instances of FpExt are element of a finite field F_p^4. They are represented as elements of
/// F_p[X] / (X^4 - 11). Basically, this is a 'big' finite field (about 2^128 elements), which is
/// used when the security of various operations depends on the size of the field. It has the field
/// Fp as a subfield, which means operations by the two are compatable, which is important. The
/// irreducible polynomial was choosen to be the simpilest possible one, x^4 - B, where 11 is the
/// smallest B which makes the polynomial irreducable.
/// Fp as a subfield, which means operations by the two are compatible, which is important. The
/// irreducible polynomial was chosen to be the simplest possible one, x^4 - B, where 11 is the
/// smallest B which makes the polynomial irreducible.
struct FpExt {
/// The elements of FpExt, elems[0] + elems[1]*X + elems[2]*X^2 + elems[3]*x^4
Fp elems[4];
Expand Down Expand Up @@ -110,7 +110,7 @@ struct FpExt {
// Now we get to the interesting case of multiplication. Basically, multiply out the polynomial
// representations, and then reduce module x^4 - B, which means powers >= 4 get shifted back 4 and
// multiplied by -beta. We could write this as a double loops with some if's and hope it gets
// unrolled properly, but it'a small enough to just hand write.
// unrolled properly, but it's small enough to just hand write.
constexpr FpExt operator*(FpExt rhs) const {
// Rename the element arrays to something small for readability
#define a elems
Expand Down Expand Up @@ -186,18 +186,18 @@ constexpr inline FpExt pow(FpExt x, size_t n) {
/// Compute the multiplicative inverse of an FpExt.
constexpr inline FpExt inv(FpExt in) {
#define a in.elems
// Compute the multiplicative inverse by basicly looking at FpExt as a composite field and using
// Compute the multiplicative inverse by basically looking at FpExt as a composite field and using
// the same basic methods used to invert complex numbers. We imagine that initially we have a
// numerator of 1, and an denominator of a. i.e out = 1 / a; We set a' to be a with the first and
// third components negated. We then multiply the numerator and the denominator by a', producing
// out = a' / (a * a'). By construction (a * a') has 0's in it's first and third elements. We
// call this number, 'b' and compute it as follows.
Fp b0 = a[0] * a[0] + BETA * (a[1] * (a[3] + a[3]) - a[2] * a[2]);
Fp b2 = a[0] * (a[2] + a[2]) - a[1] * a[1] + BETA * (a[3] * a[3]);
// Now, we make b' by inverting b2. When we muliply both sizes by b', we get out = (a' * b') /
// (b * b'). But by construcion b * b' is in fact an element of Fp, call it c.
// Now, we make b' by inverting b2. When we multiply both sizes by b', we get out = (a' * b') /
// (b * b'). But by construction b * b' is in fact an element of Fp, call it c.
Fp c = b0 * b0 + BETA * b2 * b2;
// But we can now invert C direcly, and multiply by a'*b', out = a'*b'*inv(c)
// But we can now invert C directly, and multiply by a'*b', out = a'*b'*inv(c)
Fp ic = inv(c);
// Note: if c == 0 (really should only happen if in == 0), our 'safe' version of inverse results
// in ic == 0, and thus out = 0, so we have the same 'safe' behavior for FpExt. Oh, and since we
Expand Down
10 changes: 5 additions & 5 deletions risc0/circuit/recursion-sys/cxx/fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ namespace risc0 {
/// - Otherwise have as large a power of 2 in the factors of P-1 as possible.
///
/// This last property is useful for number theoretical transforms (the fast fourier transform
/// equivelant on finite fields). See NTT.h for details.
/// equivalent on finite fields). See NTT.h for details.
///
/// The Fp class wraps all the standard arithmatic operations to make the finite field elements look
/// The Fp class wraps all the standard arithmetic operations to make the finite field elements look
/// basically like ordinary numbers (which they mostly are).
class Fp {
public:
Expand Down Expand Up @@ -80,7 +80,7 @@ class Fp {
static constexpr inline uint32_t encode(uint32_t a) { return mul(R2, a); }
static constexpr inline uint32_t decode(uint32_t a) { return mul(1, a); }

// A private constructor that take the 'interal' form.
// A private constructor that take the 'internal' form.
constexpr inline Fp(uint32_t val, bool /*ignore*/) : val(val) {}

public:
Expand Down Expand Up @@ -177,9 +177,9 @@ constexpr inline Fp pow(Fp x, size_t n) {
}

/// Compute the multiplicative inverse of x, or `1/x` in finite field terms. Since `x^(P-1) == 1
/// (mod P)` for any x != 0 (as a consequence of Fermat's little therorm), it follows that `x *
/// (mod P)` for any x != 0 (as a consequence of Fermat's little theorem), it follows that `x *
/// x^(P-2) == 1 (mod P)` for x != 0. That is, `x^(P-2)` is the multiplicative inverse of x.
/// Computed this way, the 'inverse' of zero comes out as zero, which is convient in many cases, so
/// Computed this way, the 'inverse' of zero comes out as zero, which is convenient in many cases, so
/// we leave it.
constexpr inline Fp inv(Fp x) {
return pow(x, Fp::P - 2);
Expand Down
Loading

0 comments on commit 461c57b

Please sign in to comment.