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

Resolve link warnings #1994

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/mina/account-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ interface Body extends AccountUpdateBody {
publicKey: PublicKey;

/**
* @internal
*
* Specify {@link Update}s to tweakable pieces of the account record backing
* this address in the ledger.
*/
Expand All @@ -556,6 +558,8 @@ interface Body extends AccountUpdateBody {
*/
events: Events;
/**
* @internal
*
* Recent {@link Action}s emitted from this account.
* Actions can be collected by archive nodes and used in combination with
* a {@link Reducer}.
Expand Down
48 changes: 30 additions & 18 deletions src/lib/mina/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,15 @@ type Transaction<
* await tx.send();
* ```
*/
setFee(newFee:UInt64) : TransactionPromise<Proven,false>;
setFee(newFee: UInt64): TransactionPromise<Proven, false>;
/**
* @internal
*
* setFeePerSnarkCost behaves identically to {@link Transaction.setFee} but the fee is given per estimated cost of snarking the transition as given by {@link getTotalTimeRequired}. This is useful because it should reflect what snark workers would charge in times of network contention.
*/
setFeePerSnarkCost(newFeePerSnarkCost:number) : TransactionPromise<Proven,false>;
setFeePerSnarkCost(
newFeePerSnarkCost: number
): TransactionPromise<Proven, false>;
} & (Proven extends false
? {
/**
Expand Down Expand Up @@ -274,11 +278,15 @@ type PendingTransaction = Pick<
/**
* setFee is the same as {@link Transaction.setFee(newFee)} but for a {@link PendingTransaction}.
*/
setFee(newFee:UInt64):TransactionPromise<boolean,false>;
setFee(newFee: UInt64): TransactionPromise<boolean, false>;
/**
* @internal
*
* setFeePerSnarkCost is the same as {@link Transaction.setFeePerSnarkCost(newFeePerSnarkCost)} but for a {@link PendingTransaction}.
*/
setFeePerSnarkCost(newFeePerSnarkCost:number):TransactionPromise<boolean,false>;
setFeePerSnarkCost(
newFeePerSnarkCost: number
): TransactionPromise<boolean, false>;
};

/**
Expand Down Expand Up @@ -573,24 +581,28 @@ function newTransaction(transaction: ZkappCommand, proofsEnabled?: boolean) {
}
return pendingTransaction;
},
setFeePerSnarkCost(newFeePerSnarkCost:number) {
let {totalTimeRequired} = getTotalTimeRequired(transaction.accountUpdates);
return this.setFee(new UInt64(Math.round(totalTimeRequired * newFeePerSnarkCost)));
setFeePerSnarkCost(newFeePerSnarkCost: number) {
let { totalTimeRequired } = getTotalTimeRequired(
transaction.accountUpdates
);
return this.setFee(
new UInt64(Math.round(totalTimeRequired * newFeePerSnarkCost))
);
},
setFee(newFee:UInt64) {
return toTransactionPromise(async () =>
{
self = self as Transaction<false,false>;
self.transaction.accountUpdates.forEach( au => {
if (au.body.useFullCommitment.toBoolean())
{
setFee(newFee: UInt64) {
return toTransactionPromise(async () => {
self = self as Transaction<false, false>;
self.transaction.accountUpdates.forEach((au) => {
if (au.body.useFullCommitment.toBoolean()) {
au.authorization.signature = undefined;
au.lazyAuthorization = {kind:'lazy-signature'};
au.lazyAuthorization = { kind: 'lazy-signature' };
}
});
});
self.transaction.feePayer.body.fee = newFee;
self.transaction.feePayer.lazyAuthorization = {kind : 'lazy-signature'};
return self
self.transaction.feePayer.lazyAuthorization = {
kind: 'lazy-signature',
};
return self;
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/proof-system/proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ let sideloadedKeysCounter = 0;
* NOTE: In the case of `DynamicProof`s, the circuit makes no assertions about the verificationKey used on its own.
* This is the responsibility of the application developer and should always implement appropriate checks.
* This pattern differs a lot from the usage of normal `Proof`, where the verification key is baked into the compiled circuit.
* @see {@link src/examples/zkprogram/dynamic-keys-merkletree.ts} for an example of how this can be done using merkle trees
* @see `src/examples/zkprogram/dynamic-keys-merkletree.ts` for an example of how this can be done using merkle trees
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing this link, which was not functional in any case.

*
* Assertions generally only happen using the vk hash that is part of the `VerificationKey` struct along with the raw vk data as auxiliary data.
* When using verify() on a `DynamicProof`, Pickles makes sure that the verification key data matches the hash.
Expand Down
8 changes: 6 additions & 2 deletions src/lib/provable/crypto/foreign-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Bytes } from '../bytes.js';
export { createForeignCurve, ForeignCurve };

// internal API
export { toPoint, FlexiblePoint };
export { toPoint, FlexiblePoint, ForeignCurveNotNeeded };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By exporting ForeignCurveNotNeeded, we make it linkable in other comments, where it is already in use. This makes the whole chain public.

ForeignCurveNotNeeded in particular seems weird. I'm not sure if we should just delete it in favor of ForeignCurve. See: this PR which introduces it.


type FlexiblePoint = {
x: AlmostForeignField | Field3 | bigint | number;
Expand Down Expand Up @@ -205,6 +205,7 @@ class ForeignCurve {
}

/**
* @internal
* Checks whether this curve point is constant.
*
* See {@link FieldVar} to understand constants vs variables.
Expand Down Expand Up @@ -398,6 +399,9 @@ class ForeignCurve {
}
}

/**
* @see: {@link ForeignCurve}
*/
class ForeignCurveNotNeeded extends ForeignCurve {
constructor(g: {
x: AlmostForeignField | Field3 | bigint | number;
Expand All @@ -421,7 +425,7 @@ class ForeignCurveNotNeeded extends ForeignCurve {
* const Curve = createForeignCurve(Crypto.CurveParams.Secp256k1);
* ```
*
* `createForeignCurve(params)` takes curve parameters {@link CurveParams} as input.
* `createForeignCurve(params)` takes curve parameters `CurveParams` as input.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the link to CurveParams here so that createForeignCurve can remain public, and we don't also have to make CurveParams public. This is my opinionated way of resolving, since the type CurveParams is linked in the function signature, it is quite a similar experience for the developer.

* We support `modulus` and `order` to be prime numbers up to 259 bits.
*
* The returned {@link ForeignCurveNotNeeded} class represents a _non-zero curve point_ and supports standard
Expand Down
8 changes: 5 additions & 3 deletions src/lib/provable/foreign-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ class ForeignField {
* ```ts
* let x = new ForeignField(5);
* ```
*
*
* Note: Inputs must be range checked if they originate from a different field with a different modulus or if they are not constants.
*
*
* - When constructing from another {@link ForeignField} instance, ensure the modulus matches. If not, check the modulus using `Gadgets.ForeignField.assertLessThan()` and handle appropriately.
* - When constructing from a {@link Field3} array, ensure all elements are valid Field elements and range checked.
* - When constructing from a `Field3` array, ensure all elements are valid Field elements and range checked.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing the link to Field3 here. The type is used in the function signature. The outcome here is that new ForeignField() remains public, and Field3 is private.

* - Ensure constants are correctly reduced to the modulus of the field.
*/
constructor(x: ForeignField | Field3 | bigint | number | string) {
Expand Down Expand Up @@ -129,6 +129,7 @@ class ForeignField {
}

/**
* @internal
* Checks whether this field element is a constant.
*
* See {@link FieldVar} to understand constants vs variables.
Expand All @@ -138,6 +139,7 @@ class ForeignField {
}

/**
* @internal
* Convert this field element to a constant.
*
* See {@link FieldVar} to understand constants vs variables.
Expand Down
1 change: 1 addition & 0 deletions src/lib/provable/gadgets/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export {
};

/**
* @internal
* Given a Field, collapse its AST to a pure Var. See {@link FieldVar}.
*
* This is useful to prevent rogue Generic gates added in the middle of gate chains,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/provable/gadgets/foreign-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ function assertMul(
}

/**
* @internal
*
* Lazy sum of {@link Field3} elements, which can be used as input to `Gadgets.ForeignField.assertMul()`.
*/
class Sum {
Expand Down
20 changes: 16 additions & 4 deletions src/lib/provable/gadgets/gadgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ const Gadgets = {
* Bitwise AND gadget on {@link Field} elements. Equivalent to the [bitwise AND `&` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_AND).
* The AND gate works by comparing two bits and returning `1` if both bits are `1`, and `0` otherwise.
*
* It can be checked by a double generic gate that verifies the following relationship between the values
* It can be checked by a double generic gate that verifies the following relationship between the values
* below (in the process it also invokes the {@link Gadgets.xor} gadget which will create additional constraints depending on `length`).
*
* The generic gate verifies:\
Expand All @@ -452,7 +452,7 @@ const Gadgets = {
* You can find more details about the implementation in the [Mina book](https://o1-labs.github.io/proof-systems/specs/kimchi.html?highlight=gates#and)
*
* The `length` parameter lets you define how many bits should be compared. `length` is rounded
* to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values
* to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values
* are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well.
*
* **Note:** Specifying a larger `length` parameter adds additional constraints.
Expand All @@ -476,8 +476,8 @@ const Gadgets = {
* Bitwise OR gadget on {@link Field} elements. Equivalent to the [bitwise OR `|` operator in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR).
* The OR gate works by comparing two bits and returning `1` if at least one bit is `1`, and `0` otherwise.
*
* The `length` parameter lets you define how many bits should be compared. `length` is rounded
* to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values
* The `length` parameter lets you define how many bits should be compared. `length` is rounded
* to the nearest multiple of 16, `paddedLength = ceil(length / 16) * 16`, and both input values
* are constrained to fit into `paddedLength` bits. The output is guaranteed to have at most `paddedLength` bits as well.
*
* **Note:** Specifying a larger `length` parameter adds additional constraints.
Expand Down Expand Up @@ -685,6 +685,8 @@ const Gadgets = {
},

/**
* @internal
*
* Foreign field multiplication: `x * y mod f`
*
* The modulus `f` does not need to be prime, but has to be smaller than 2^259.
Expand Down Expand Up @@ -722,6 +724,8 @@ const Gadgets = {
},

/**
* @internal
*
* Foreign field inverse: `x^(-1) mod f`
*
* See {@link Gadgets.ForeignField.mul} for assumptions on inputs and usage examples.
Expand All @@ -733,6 +737,8 @@ const Gadgets = {
},

/**
* @internal
*
* Foreign field division: `x * y^(-1) mod f`
*
* See {@link Gadgets.ForeignField.mul} for assumptions on inputs and usage examples.
Expand All @@ -746,6 +752,8 @@ const Gadgets = {
},

/**
* @internal
*
* Optimized multiplication of sums in a foreign field, for example: `(x - y)*z = a + b + c mod f`
*
* Note: This is much more efficient than using {@link Gadgets.ForeignField.add} and {@link Gadgets.ForeignField.sub} separately to
Expand Down Expand Up @@ -789,13 +797,17 @@ const Gadgets = {
},

/**
* @internal
*
* Lazy sum of {@link Field3} elements, which can be used as input to {@link Gadgets.ForeignField.assertMul}.
*/
Sum(x: Field3) {
return ForeignField.Sum(x);
},

/**
* @internal
*
* Prove that each of the given {@link Field3} elements is "almost" reduced modulo f,
* i.e., satisfies the assumptions required by {@link Gadgets.ForeignField.mul} and other gadgets:
* - each limb is in the range [0, 2^88)
Expand Down
10 changes: 5 additions & 5 deletions src/lib/provable/int.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class UInt64 extends CircuitValue {
return this.value.toString();
}
/**
* Turns the {@link UInt64} into a {@link BigInt}.
* Turns the {@link UInt64} into a BigInt.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why you removed the BigInt link?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BigInt is also invisible to the docs, so a typedoc warning is raised here.

I thought BigInt is generic enough that people know what we mean, but I could replace this with an http link to some bigint docs, or look for another workaround to keep the intellisense link here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would also be valid to turn this rule off like we did with notExported in #1993. I think it is worth knowing if there is a typo in a link or if a public API is referencing private APIs, and resolving those, rather than ignoring. But if it becomes too much effort, or too much value is lost by working around this rule, we can just turn it off too.

* @returns
*/
toBigInt() {
Expand Down Expand Up @@ -575,7 +575,7 @@ class UInt32 extends CircuitValue {
return this.value.toString();
}
/**
* Turns the {@link UInt32} into a {@link BigInt}.
* Turns the {@link UInt32} into a BigInt.
*/
toBigint() {
return this.value.toBigInt();
Expand Down Expand Up @@ -1214,7 +1214,7 @@ class Int64 extends CircuitValue implements BalanceChange {
}

/**
* Turns the {@link Int64} into a {@link BigInt}.
* Turns the {@link Int64} into a BigInt.
*/
toBigint() {
let abs = this.magnitude.toBigInt();
Expand Down Expand Up @@ -1287,8 +1287,8 @@ class Int64 extends CircuitValue implements BalanceChange {
* Int64.from(5).neg();
* ```
*
* @see {@link Int64#from} for creating Int64 instances
* @see {@link Int64#zero} for the zero constant
* @see {@link Int64.from} for creating Int64 instances
* @see {@link Int64.zero} for the zero constant
*
* @throws {Error} Implicitly, if the internal Provable.if condition fails
*/
Expand Down
1 change: 1 addition & 0 deletions src/lib/provable/provable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const Provable = {
*/
Array: provableArray,
/**
* @internal
* Check whether a value is constant.
* See {@link FieldVar} for more information about constants and variables.
*
Expand Down
2 changes: 2 additions & 0 deletions src/lib/provable/scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Scalar implements ShiftedScalar {
}

/**
* @internal
* Provable method to convert a {@link ShiftedScalar} to a {@link Scalar}.
*/
static fromShiftedScalar(s: ShiftedScalar) {
Expand All @@ -78,6 +79,7 @@ class Scalar implements ShiftedScalar {
}

/**
* @internal
* Convert this {@link Scalar} into a constant if it isn't already.
*
* If the scalar is a variable, this only works inside `asProver` or `witness` blocks.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/provable/types/provable-intf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Provable<T, TValue = any> = {
/**
* A function that returns an element of type `T` from the given provable and "auxiliary" data.
*
* This function is the reverse operation of calling {@link toFields} and {@link toAuxilary} methods on an element of type `T`.
* This function is the reverse operation of calling {@link toFields} and {@link toAuxiliary} methods on an element of type `T`.
*
* @param fields - an array of {@link Field} elements describing the provable data of the new `T` element.
* @param aux - an array of any type describing the "auxiliary" data of the new `T` element, optional.
Expand Down
3 changes: 3 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
},
"entryPoints": [
"src/index.ts",
"src/lib/mina/account-update.ts",
"src/lib/provable/crypto/foreign-curve.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Foreign curves are already public: https://docs.minaprotocol.com/zkapps/o1js-reference/classes/ForeignCurve

This change makes all the doc comments exposed in the file available for other files to reference in @links.

"src/lib/provable/field.ts",
"src/lib/provable/foreign-field.ts",
"src/lib/provable/bool.ts",
"src/lib/provable/group.ts",
"src/lib/provable/int.ts",
Expand Down
Loading