Skip to content

Commit

Permalink
improve subtract code, add negate()
Browse files Browse the repository at this point in the history
  • Loading branch information
adraffy committed Sep 29, 2024
1 parent f90a239 commit 7078864
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
ProofSequenceV1,
Provider,
} from './types.js';
import { ZeroAddress, ZeroHash, MaxUint256 } from 'ethers/constants';
import { ZeroAddress, ZeroHash } from 'ethers/constants';
import { Contract } from 'ethers/contract';
import { Interface } from 'ethers/abi';
import { keccak256 } from 'ethers/crypto';
Expand Down Expand Up @@ -256,8 +256,11 @@ export class GatewayProgram {
plus() {
return this.addByte(OP.PLUS);
}
negate() {
return this.not().push(1).plus(); // twos complement
}
subtract() {
return this.push(MaxUint256).plus().not().plus(); // TODO: add op?
return this.negate().plus();
}
times() {
return this.addByte(OP.TIMES);
Expand Down

0 comments on commit 7078864

Please sign in to comment.