Skip to content

Commit

Permalink
Merge pull request #55 from DevelBlockchain/feat/phe-init
Browse files Browse the repository at this point in the history
insert phe
  • Loading branch information
felipemarts authored Sep 13, 2024
2 parents 76a4640 + 4586dee commit bee4d79
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 4 deletions.
16 changes: 16 additions & 0 deletions imports/phe.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const pheEncrypt = (publicKey) => {
return blockchain.pheEncrypt(publicKey);
}
const pheSum = (publicKey, numberA, numberB) => {
return blockchain.pheSum(publicKey, numberA, numberB);
}
const pheMultiply = (publicKey, numberA, k) => {
return blockchain.pheMultiply(publicKey, numberA, k);
}

const phe = {
pheEncrypt,
pheSum,
pheMultiply
}
export default phe;
26 changes: 24 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"https": "^1.0.0",
"jsonwebtoken": "^9.0.0",
"level": "^8.0.0",
"paillier-bigint": "^3.4.3",
"pidusage": "^3.0.2",
"quickjs-emscripten": "^0.29.2",
"randomstring": "^1.2.2",
Expand Down
17 changes: 16 additions & 1 deletion src/vm/BlockchainInterface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import helper from '../utils/helper';
import { RuntimeContext } from './RuntimeContext';
import { BywiseRuntimeInstance } from './BywiseRuntimeInstance';
import BigNumber from 'bignumber.js';
import { BywiseHelper, TransactionEvent, TransactionEventEntry } from '@bywise/web3';
import { WalletScriptDTO } from '../types';

Expand Down Expand Up @@ -226,6 +225,19 @@ export default class BlockchainInterface {
throw new Error(`BVM: not implemented`);
}

pheEncrypt = async(vm: BywiseRuntimeInstance, ctx: RuntimeContext, publicKey:string): Promise<string> =>{
throw new Error(`BVM: not implemented`);
}

pheSum = async(vm: BywiseRuntimeInstance, ctx: RuntimeContext, publicKey:string , numberA:string , numberB:string): Promise<string> =>{
throw new Error(`BVM: not implemented`);
}

pheMultiply = async(vm: BywiseRuntimeInstance, ctx: RuntimeContext, publicKey:string, numberA:string , k:string): Promise<string> =>{
throw new Error(`BVM: not implemented`);
}


exposeMethods = () => {
const methods: BlockchainAction[] = [];
methods.push({ action: this.set, name: 'set' });
Expand All @@ -251,6 +263,9 @@ export default class BlockchainInterface {
methods.push({ action: this.newProxyAction, name: 'newProxyAction' });
methods.push({ action: this.costProxyAction, name: 'costProxyAction' });
methods.push({ action: this.readProxyAction, name: 'readProxyAction' });
methods.push({ action: this.pheEncrypt, name: 'pheEncrypt' });
methods.push({ action: this.pheSum, name: 'pheSum' });
methods.push({ action: this.pheMultiply, name: 'pheMultiply' });
return methods;
}
}
4 changes: 3 additions & 1 deletion src/vm/BywiseRuntimeInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const PRESET = [
"Date = EditDate;",
].join('\n');
const FILE_BYWISE_UTILS = fs.readFileSync(path.join(__dirname, '../../imports/bywise-utils.mjs'), "utf-8")
const FILE_PHE = fs.readFileSync(path.join(__dirname, '../../imports/phe.mjs'), "utf-8")
const imports = [
{ module: "bywise-utils", binary: FILE_BYWISE_UTILS }
{ module: "bywise-utils", binary: FILE_BYWISE_UTILS },
{ module: "phe", binary: FILE_PHE }
]

export class BywiseRuntimeInstance {
Expand Down

0 comments on commit bee4d79

Please sign in to comment.