Skip to content

Commit

Permalink
Merge branch 'main' into feat/mina-submodule-support
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMinkov committed Dec 14, 2023
2 parents 225dd0a + 61c75c0 commit 9669d55
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
21 changes: 12 additions & 9 deletions mina-transaction/derived-leaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ const tokenSymbolLength = 6;
function derivedLeafTypes<Field, Bool>({
Field,
Bool,
Hash,
HashHelpers,
packToFields,
}: {
Field: GenericField<Field>;
Bool: GenericBool<Field, Bool>;
Hash: HashHelpers<Field>;
HashHelpers: HashHelpers<Field>;
packToFields: (input: GenericHashInput<Field>) => Field[];
}) {
let { provable } = createDerivers<Field>();
Expand All @@ -57,19 +57,19 @@ function derivedLeafTypes<Field, Bool>({
}),
Bool
),
ZkappUri: createZkappUri(Field, Hash, packToFields),
ZkappUri: createZkappUri(Field, HashHelpers, packToFields),
};
}

function derivedLeafTypesSignable<Field, Bool>({
Field,
Bool,
Hash,
HashHelpers,
packToFields,
}: {
Field: GenericSignableField<Field>;
Bool: GenericSignableBool<Field, Bool>;
Hash: HashHelpers<Field>;
HashHelpers: HashHelpers<Field>;
packToFields: (input: GenericHashInput<Field>) => Field[];
}) {
let { signable } = createDerivers<Field>();
Expand All @@ -95,7 +95,7 @@ function derivedLeafTypesSignable<Field, Bool>({
}),
Bool
),
ZkappUri: createZkappUri(Field, Hash, packToFields),
ZkappUri: createZkappUri(Field, HashHelpers, packToFields),
};
}

Expand Down Expand Up @@ -196,7 +196,7 @@ function createAuthRequired<

function createZkappUri<Field>(
Field: GenericSignableField<Field>,
Hash: HashHelpers<Field>,
HashHelpers: HashHelpers<Field>,
packToFields: (input: GenericHashInput<Field>) => Field[]
) {
// Mina_base.Zkapp_account.hash_zkapp_uri_opt
Expand All @@ -207,12 +207,15 @@ function createZkappUri<Field>(
packed: bits.map((b) => [Field(Number(b)), 1]),
};
let packed = packToFields(input);
return Hash.hashWithPrefix(prefixes.zkappUri, packed);
return HashHelpers.hashWithPrefix(prefixes.zkappUri, packed);
}

return dataAsHash<string, string, Field>({
empty() {
let hash = Hash.hashWithPrefix(prefixes.zkappUri, [Field(0), Field(0)]);
let hash = HashHelpers.hashWithPrefix(prefixes.zkappUri, [
Field(0),
Field(0),
]);
return { data: '', hash };
},
toJSON(data: string) {
Expand Down
6 changes: 3 additions & 3 deletions mina-transaction/transaction-leaves-bigint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { derivedLeafTypesSignable } from './derived-leaves.js';
import { createEvents } from '../../lib/events.js';
import {
Poseidon,
Hash,
HashHelpers,
packToFields,
} from '../../provable/poseidon-bigint.js';
import { mocks } from '../crypto/constants.js';
Expand Down Expand Up @@ -39,7 +39,7 @@ type TokenSymbol = { symbol: string; field: Field };
type ZkappUri = { data: string; hash: Field };

const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri } =
derivedLeafTypesSignable({ Field, Bool, Hash, packToFields });
derivedLeafTypesSignable({ Field, Bool, HashHelpers, packToFields });

type Event = Field[];
type Events = {
Expand All @@ -64,5 +64,5 @@ const VerificationKeyHash = {
type ReceiptChainHash = Field;
const ReceiptChainHash = {
...Field,
empty: () => Hash.emptyHashWithPrefix('CodaReceiptEmpty'),
empty: () => HashHelpers.emptyHashWithPrefix('CodaReceiptEmpty'),
};
4 changes: 2 additions & 2 deletions mina-transaction/transaction-leaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { derivedLeafTypes } from './derived-leaves.js';
import { createEvents } from '../../lib/events.js';
import {
Poseidon,
Hash,
HashHelpers,
packToFields,
emptyHashWithPrefix,
} from '../../lib/hash.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ type TokenSymbol = { symbol: string; field: Field };
type ZkappUri = { data: string; hash: Field };

const { TokenId, StateHash, TokenSymbol, AuthRequired, ZkappUri } =
derivedLeafTypes({ Field, Bool, Hash, packToFields });
derivedLeafTypes({ Field, Bool, HashHelpers, packToFields });

type Event = Field[];
type Events = {
Expand Down

0 comments on commit 9669d55

Please sign in to comment.