Skip to content

Commit

Permalink
addresses got new notes about key length validity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalmechanism committed Apr 8, 2024
1 parent 1cf2f81 commit 478d5b7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# v0.x.y

- Updating documentation
- Functions should be curryable, f |> g |> h
- Functions should be curryable, f |> g |> h. An updated list of functions are below.
- values.contains
- values.prove_nft
- values.prove_exact_nft
- values.unique_token_name will remove the hash function in step one for versions of assist v0.5.0+
- v0.4.x will keep the hash function to prevent breaking old code
- Addresses now have notes about key length validity checks. Please use Wallet types with `wallet.is_valid`.

# v0.4.7

Expand Down
17 changes: 13 additions & 4 deletions lib/assist/addresses.ak
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//// This module incorporates code for generating valid wallet and script
//// addresses, ensuring their correctness. Empty keys are treated as
//// intentional, and address subtypes are not combined nor mixed.
//// intentional, and address subtypes are not combined nor mixed. The key
//// lengths must be validated on their own as these functions are used to
//// just generate Address types assuming valid key lengths.
////

use aiken/bytearray
Expand All @@ -10,7 +12,9 @@ use aiken/transaction/credential.{
use assist/types/hashes.{PublicKeyHash, ValidatorHash}
use assist/types/wallet.{Wallet}

/// Creates an address from the wallet type.
/// Creates an address from the Wallet type. This should be used primairly for
/// creating an address as the Wallet type has a `is_valid` function that should
/// be used in the same validaiton.
///
/// ```aiken
/// let addr: Address = types.from_wallet(this_wallet)
Expand All @@ -21,7 +25,10 @@ pub fn from_wallet(wallet: Wallet) -> Address {

/// Creates a enterprise or base address from the public key hash and stake
/// credential. An empty sc means enterpise address by default. This function
/// assumes proper key lengths for `pkh` and `sc`.
/// assumes proper key lengths for `pkh` and `sc`. Again, this function does not
/// check if the stake credential has a proper length. Address
/// types should be generated from the Wallet type so proper length checks are
/// done with the `wallet.is_valid` function.
///
/// ```aiken
/// addresses.create_address(datum.wallet.pkh, datum.wallet.sc)
Expand Down Expand Up @@ -66,7 +73,9 @@ test correct_wallet_sc() {
/// Creates a script address for a smart contract. The type does not mix address
/// types. Staked smart contracts are contracts as well. An empty sc is
/// assumed to be not staked. This function assumes proper key lengths for `vkh`
/// and `sc`.
/// and `sc`. Again, this function does not check if the stake credential has a
/// proper length. Address types should be generated from the Wallet type so
/// proper length checks are done with the `wallet.is_valid` function.
///
/// ```aiken
/// addresses.create_script_address(datum.script.vkh, datum.script.sc)
Expand Down
26 changes: 13 additions & 13 deletions lib/assist/circuits.ak
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ fn do_pos_shift(r: Int, p: Int) -> Int {
}
}

// this can get expensive
test do_pos_shift_test1() {
let r = -1975180248
let p: Int = 44203
do_pos_shift(r, p) == r + 44685 * p
}

test do_pos_shift_test2() {
let r = -15
let p: Int = 44203
do_pos_shift(r, p) == r + 1 * p
}

/// Performs a logical `AND` operation on two integer values within an arithmetic circuit.
///
/// ```aiken
Expand Down Expand Up @@ -72,19 +85,6 @@ pub fn or_(x: Int, y: Int, p: Int) -> Int {
do_pos_shift(r, p)
}

// this can get expensive
test do_pos_shift_test1() {
let r = -1975180248
let p: Int = 44203
do_pos_shift(r, p) == r + 44685 * p
}

test do_pos_shift_test2() {
let r = -15
let p: Int = 44203
do_pos_shift(r, p) == r + 1 * p
}

// Identity and Dominance tests
test identity_or() {
let p: Int = 44203
Expand Down

0 comments on commit 478d5b7

Please sign in to comment.