Skip to content

Commit

Permalink
corrected the peheli app. The signature now works correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaysaha committed Jan 13, 2024
1 parent b0e7130 commit 01a0f83
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 145 deletions.
135 changes: 8 additions & 127 deletions src/native_tokens/frontend/peheli/package-lock.json

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

2 changes: 1 addition & 1 deletion src/native_tokens/frontend/peheli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"uuid": "^8.3.2",
"vue": "^2.7.12",
"vue-material": "^1.0.0-beta-15",
"web3-slib": "1.0.1"
"web3-cardano-token-rc": "0.0.17"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.19",
Expand Down
31 changes: 14 additions & 17 deletions src/native_tokens/frontend/peheli/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<script>
const uniqueId = require('uuid')
import * as S from "@emurgo/cardano-serialization-lib-asmjs";
//import Web3Token from 'web3-slib/dist/browser';
import Web3Token from 'web3-cardano-token-rc/dist/browser';
//import * as M from "@meshsdk/core"
export default {
Expand Down Expand Up @@ -565,25 +565,26 @@ export default {
//The "type" of message can be: "walletLogin", "DaoCreation", "DaoMembership", "HouseFractionalise" etc.
const msgKPairs = await this.generateMessagingKeys()
//store the key pairs.
await this.lstore('ecdh_private_key', msgKPairs.privateKeyJwk, 'set')
await this.lstore('ecdh_public_key', msgKPairs.publicKeyJwk, 'set')
const nonce = 123
const msg = {
'type': "walletLogin",
'chainID': (await this.API.getNetworkId()).toString(),
'msgPublicKey': JSON.stringify(msgKPairs.publicKeyJwk),
"nonce":123,
"nonce": nonce.toString(),
"domain": window.location.hostname,
"expiry": expiry_date
"expiry": expiry_date.toString()
};
//store the key pairs.
await this.lstore('ecdh_private_key', msgKPairs.privateKeyJwk, 'set')
await this.lstore('ecdh_public_key', msgKPairs.publicKeyJwk, 'set')
const wallet_signing_function = async (msg) => {
const Buffer = (await import('buffer/')).Buffer
const Buffer = (await import('buffer/')).Buffer
const paddress = await this.API.getRewardAddresses();
const msg_hex = Buffer.from(JSON.stringify(msg), 'utf-8').toString("hex")
const msg_hex = Buffer.from(msg, 'utf-8').toString("hex")
const signdata = await this.API.signData(saddress[0], msg_hex)
console.log(signdata)
Expand All @@ -592,14 +593,10 @@ export default {
// const signed_data = await this.API.signData(saddress[0], msg_hex)
// console.log(signed_data)
//const token = await Web3Token.sign(m => this.API.signData(saddress[0], msg_hex), '1d', )
// const nonce = 123 //to be finally obtained via api using the wallet address
// const token = await Web3Token.signWallet(wallet_signing_function, '365d', msg, nonce )
const signdata = await wallet_signing_function(msg)
const token = await Web3Token.sign(wallet_signing_function, '365d', msg )
console.log(signdata)
console.log(token)
}
catch(err){
console.error(err)
Expand Down

0 comments on commit 01a0f83

Please sign in to comment.