mirror of
git://jb55.com/damus
synced 2024-09-05 21:03:51 +00:00
key: generate a FullKeypair when generating new keys
This commit is contained in:
parent
616de2eebc
commit
88306d00a3
@ -38,8 +38,8 @@ class CreateAccountModel: ObservableObject {
|
||||
init(real: String = "", nick: String = "", about: String = "") {
|
||||
let keypair = generate_new_keypair()
|
||||
self.pubkey = keypair.pubkey
|
||||
self.privkey = keypair.privkey!
|
||||
|
||||
self.privkey = keypair.privkey
|
||||
|
||||
self.real_name = real
|
||||
self.nick_name = nick
|
||||
self.about = about
|
||||
|
@ -659,7 +659,7 @@ func make_zap_request_event(keypair: FullKeypair, content: String, relays: [Rela
|
||||
break
|
||||
case .anon:
|
||||
tags.append(["anon"])
|
||||
kp = generate_new_keypair().to_full()!
|
||||
kp = generate_new_keypair()
|
||||
case .priv:
|
||||
guard let priv_kp = generate_private_keypair(our_privkey: keypair.privkey, id: target.id, created_at: now) else {
|
||||
return nil
|
||||
|
@ -102,11 +102,11 @@ func bech32_note_id(_ evid: String) -> String? {
|
||||
return bech32_encode(hrp: "note", bytes)
|
||||
}
|
||||
|
||||
func generate_new_keypair() -> Keypair {
|
||||
func generate_new_keypair() -> FullKeypair {
|
||||
let key = try! secp256k1.Signing.PrivateKey()
|
||||
let privkey = hex_encode(key.rawRepresentation)
|
||||
let pubkey = hex_encode(Data(key.publicKey.xonly.bytes))
|
||||
return Keypair(pubkey: pubkey, privkey: privkey)
|
||||
return FullKeypair(pubkey: pubkey, privkey: privkey)
|
||||
}
|
||||
|
||||
func privkey_to_pubkey_raw(sec: [UInt8]) -> Pubkey? {
|
||||
|
@ -19,7 +19,7 @@ struct CreateAccountView: View {
|
||||
func regen_key() {
|
||||
let keypair = generate_new_keypair()
|
||||
self.account.pubkey = keypair.pubkey
|
||||
self.account.privkey = keypair.privkey!
|
||||
self.account.privkey = keypair.privkey
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
@ -110,7 +110,7 @@ struct KeySettingsView: View {
|
||||
struct KeySettingsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let kp = generate_new_keypair()
|
||||
KeySettingsView(keypair: kp)
|
||||
KeySettingsView(keypair: kp.to_keypair())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import XCTest
|
||||
|
||||
final class UserSearchCacheTests: XCTestCase {
|
||||
|
||||
var keypair: Keypair? = nil
|
||||
var keypair: FullKeypair? = nil
|
||||
let damusState = DamusState.empty
|
||||
let nip05 = "_@somedomain.com"
|
||||
|
||||
|
@ -20,8 +20,8 @@ final class ZapTests: XCTestCase {
|
||||
}
|
||||
|
||||
func test_private_zap() throws {
|
||||
let alice = generate_new_keypair().to_full()!
|
||||
let bob = generate_new_keypair().to_full()!
|
||||
let alice = generate_new_keypair()
|
||||
let bob = generate_new_keypair()
|
||||
let target = ZapTarget.profile(bob.pubkey)
|
||||
|
||||
let message = "hey bob!"
|
||||
|
Loading…
Reference in New Issue
Block a user