Skip to content

Commit 85e8041

Browse files
author
Polybase CI
committed
Merge remote-tracking branch 'origin/main' into release
2 parents c2f6a89 + 751c266 commit 85e8041

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

api-reference/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Authentication is composed of:
1818
- `t` current unix timestamp in milliseconds
1919
- `h` type of hash signing being used `eth-personal-sign` is currently the only allowed option
2020
- `sig` the signature of the data (see below)
21-
- `pk` **optional** 65 byte public key (secp256k1 algorithm)
21+
- `pk` **optional** 64 byte public key (secp256k1 algorithm)
2222

2323

2424
An example of a valid authroization:

authentication.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,16 @@ The `authState` for **Metamask** login would be:
138138
Metamask does not currently provide the `publicKey` directly but it can be obtained by signing a request.
139139
140140
```js
141+
import { ethPersonalSignRecoverPublicKey } from '@polybase/eth'
142+
import { } from '@polybase/util'
143+
141144
const msg = 'Login to app'
142145
const sig = await auth.ethPersonalSign(msg)
143-
const publicKey = ethPersonalSignRecoverPublicKey(sig, msg)
146+
// Returns a hex string of the public key (65 bytes), you will need to convert to 64 bytes to use
147+
// with Polybase
148+
const publicKey65Bytes = ethPersonalSignRecoverPublicKey(sig, msg)
149+
// Now it can be used with Polybase
150+
const publicKey64Bytes = '0x' + publicKey65Bytes.slice(4)
144151
```
145152
146153

encrypt-data.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ There are a number of different algorithms, but we recommend using `secp256k1` (
7575
import { secp256k1, decodeFromString, encodeToString, EncryptedDataSecp256k1 } from '@polybase/util'
7676

7777
// Public and private key as UInt8Array
78-
const { publicKey, privateKey } = await secp256k1.generateKeyPair()
78+
const privateKey = generatePrivateKey()
79+
const publicKey = secp256k1.getPublicKey64()
7980

8081
export async function asymmmetricEncryptString (publicKey: Uint8Array, str: string): Promise<EncryptedDataSecp256k1> {
8182

mint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Polybase",
33
"versions": [
4-
"0.6.4"
4+
"0.6.5"
55
],
66
"logo": {
77
"light": "/logo/light.svg",

write-data.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ import { secp256k1 } from '@polybase/util'
228228

229229
async function createWallet () {
230230
// First time the user signs up to your dapp (generate key AKA wallet)
231-
const { privateKey, publicKey } = await secp256k1.generateKeyPair()
231+
const privateKey = await secp256k1.generatePrivateKey()
232232

233233
const db = new Polybase({ defaultNamespace: "your-namespace" })
234234

@@ -243,7 +243,7 @@ async function createWallet () {
243243
return { h: 'eth-personal-sign', sig: ethPersonalSign(privateKey, data) }
244244
})
245245

246-
return { privateKey, publicKey }
246+
return { privateKey, publicKey: secp256k1.getPublicKey64(privateKey) }
247247
}
248248
```
249249

@@ -327,7 +327,8 @@ const db = new Polybase({ defaultNamespace: "your-namespace" });
327327

328328
async function createWallet () {
329329
// First time the user signs up to your dapp (generate key pair AKA wallet)
330-
const { privateKey, publicKey } = await secp256k1.generateKeyPair();
330+
const privateKey = secp256k1.generatePrivateKey()
331+
const publicKey = secp256k1.getPublicKey64(privateKey)
331332

332333
// Encrypted value will be returned as a hex string 0x...
333334
const encryptedValueAsHexStr = await secp256k1.asymmetricEncryptToEncoding(

0 commit comments

Comments
 (0)