Skip to content

Commit a90534b

Browse files
committed
feat: add stub for v11 op code mimc
1 parent 5e6478b commit a90534b

File tree

9 files changed

+493
-345
lines changed

9 files changed

+493
-345
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"eslint-plugin-prettier": "^5.2.1",
5252
"npm-run-all": "4.1.5",
5353
"patch-package": "^8.0.0",
54+
"polytype": "^0.17.0",
5455
"prettier": "3.3.3",
5556
"rimraf": "6.0.1",
5657
"rollup": "^4.24.0",

src/impl/crypto.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { arc4, bytes, Bytes, Ecdsa, gtxn, internal, VrfVerify } from '@algorandfoundation/algorand-typescript'
1+
import { arc4, bytes, Bytes, Ecdsa, gtxn, internal, MimcConfigurations, VrfVerify } from '@algorandfoundation/algorand-typescript'
22
import elliptic from 'elliptic'
33
import js_sha256 from 'js-sha256'
44
import js_sha3 from 'js-sha3'
@@ -143,6 +143,10 @@ export const EllipticCurve = new Proxy({} as internal.opTypes.EllipticCurveType,
143143
},
144144
})
145145

146+
export const mimc = (_c: MimcConfigurations, _a: internal.primitives.StubBytesCompat): bytes => {
147+
notImplementedError('mimc')
148+
}
149+
146150
const curveMap = {
147151
[Ecdsa.Secp256k1]: 'secp256k1',
148152
[Ecdsa.Secp256r1]: 'p256',

tests/artifacts/crypto-ops/contract.algo.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
import { arc4, bytes, Ecdsa, ensureBudget, op, OpUpFeeSource, uint64, VrfVerify } from '@algorandfoundation/algorand-typescript'
1+
import {
2+
arc4,
3+
bytes,
4+
Ecdsa,
5+
ensureBudget,
6+
MimcConfigurations,
7+
op,
8+
OpUpFeeSource,
9+
uint64,
10+
VrfVerify,
11+
} from '@algorandfoundation/algorand-typescript'
212
import { Bool } from '@algorandfoundation/algorand-typescript/arc4'
313

414
export class CryptoOpsContract extends arc4.Contract {
@@ -91,4 +101,11 @@ export class CryptoOpsContract extends arc4.Contract {
91101
const result = op.vrfVerify(VrfVerify.VrfAlgorand, a, b, c)
92102
return result
93103
}
104+
105+
@arc4.abimethod()
106+
public verify_mimc(a: bytes): bytes {
107+
ensureBudget(5700, OpUpFeeSource.GroupCredit)
108+
const result = op.mimc(MimcConfigurations.BN254Mp110, a)
109+
return result
110+
}
94111
}

0 commit comments

Comments
 (0)