签名文本文件,报错invalid address
-
签名文本文件,报错invalid address
-
你好,由于没有具体的代码,我们没法完全准确的分析你的问题。
但根据报错信息"invalid address"来看,是signature和对应的address不匹配导致的。请你检查一下,
- Header中传递的 “x-po-auth-address” 是不是对应用户的address?
- Header中传递的 “x-po-auth-sig” 是否是由对应用户的私钥签名的?
-
如果还有问题,请提供详细的Demo,我们能更准确定位你的问题。
同时我们也会完善文档,提供更详细的示例。
-
@zhangpeng 在 签名文本文件,报错invalid address 中说:
signature
global.user = {
email: '18091595372@163.com',
keystore: '{"address":"8016da1ba99d0d50450d5a32f00412de1e35b9ed","crypto":{"cipher":"aes-128-ctr","ciphertext":"91059f14ca6f4e57841668bea56fbbcf3b7e5a75185bd42617af5d9d030c1942","cipherparams":{"iv":"b7e9da7886a2f302cf86e7444dc912d9"},"mac":"3663ebe2b8319b34df3929b493ec8e96c4afc1c5ffba3a42a9eb9c0fa9443263","kdf":"pbkdf2","kdfparams":{"c":262144,"dklen":32,"prf":"hmac-sha256","salt":"981025719eff29e942ffa5b5a3c9edd73dc1f3d700839f8e43b0a22e3ed028e4"}},"id":"9891e2bf-2006-4d56-8d71-1fabe998a487","version":3}',
password: '不宜透露',
address: '8016da1ba99d0d50450d5a32f00412de1e35b9ed',
privateKey: 'd944e6d3e61fd630963d3a399dc3e88d54575fa0aaddbd231cf491e56a30b44b',
// must use valid mixin to withdraw and both of them have limitation for withdraw every day
validMixinIds: [
'7ee1941f-30db-417b-8c82-c71e2d8a3e8c'
],
};//签名
fs.writeFileSync(url, data, 'utf-8');
const content = fs.readFileSync(url, 'utf-8');
const sign = utility.signFileViaKey(content, user.privateKey);
global.api.post(
'/api/filesign'
).field(
'sig', sign.sig
).field(
'address', user.address
).field(
'title', 'testing title'
).field(
'source', 'Google'
).field(
'originUrl', 'https://www.google.com'
).attach(
'file', url
).set('Accept', 'application/json').end((err, res) => {
console.log(res.body);
});
上面sign计算完全是官方SDK的计算,什么都没改动
-
@zhangpeng 排查了你上面说的问题,都是没有问题的
-
@delover 在 签名文本文件,报错invalid address 中说:
invalid address
你好,经过查看,应该是你的 address 和 privateKey不匹配导致的。
你可以使用keythereum.recover来获取对应的privateKey,同时请保存好privateKey,它跟你的密码一样重要。
keythereum.recover(password, JSON.parse(keystore))
或者直接使用keystore和password来进行签名。
const signFile = (content, keystore, password) => { return signFileViaKey( content, keythereum.recover(password, JSON.parse(keystore)) ); }
完整示例:
describe('sign file', () => { it('should return a 200 response', function(done) { const content = fs.readFileSync(url, 'utf-8'); const sign = utility.signFile(content, user.keystore, user.password); global.api.post( '/api/filesign' ).field( 'sig', sign.sig ).field( 'address', user.address ).field( 'title', 'testing title' ).field( 'source', 'Google' ).field( 'originUrl', 'https://www.google.com' ).attach( 'file', url ).set('Accept', 'application/json').end((err, res) => { console.log(res.body); res.status.should.equal(200); msghash = res.body.block.msghash; done(); }); this.timeout(1000 * 200); }); });
-
这是创建APP完成返回的数据,签名用到的address和privatekey的值分别是ownerAddress和privateKey,还是报错: { message: 'invalid user address', errors: {} }
-
@delover 在 签名文本文件,报错invalid address 中说:
授权完以后,再签名的话,还是报错:unauthorized user or app是怎么会事儿?授权返回的信息: "body": {
"errors": [],
"data": {
"appAuthentication": {
"id": 1791,
"userAddress": "4cbafe7d20558d964d784c19852cca3fad2700bf",
"status": "VERIFIED",
"createdAt": "2018-12-25T03:39:30.000Z",
"updatedAt": "2018-12-25T03:39:30.000Z",
"signature": "1887443a15fd4c33b77a3f1078b670d1d7cb379c362cf29d27f2e9e86fd817d555fc36e2b84ac37202f9f2659c13510ea4fe5601ec10ab3cbcfa733899e39bae0",
"appAddress": "c0cf361e74bc5bfb5abec8e8b7fdb29d3cbc0150",
"authAddress": "82e2b4d49cb962e3bf9b0c46fbfdf3f8e7fd9684"
}
},
"success": true
}
-
This post is deleted!
-
This post is deleted!