--- Log opened Fri Oct 31 00:00:24 2025 05:37 < yancy> Wouldn't it be wise to generate a private_key and an address as a pair, similar to how `secp.generate_keypair` return a matching secret_key and public_key. 05:38 < yancy> I was surprised that it's possible to create a private key for a different network then the address, which feels like a easy way to make a mistake. 05:38 < yancy> example: 05:38 < yancy> let private_key = PrivateKey::new(secret_key, Network::Bitcoin); 05:38 < yancy> let address = Address::p2wpkh(public_key, Network::Testnet); 05:39 < yancy> in other-words, if you wrote down the private_key, it might not correspond to the address, even if the secret_key and public_key are matching pair 06:05 < Ademan> I've never used PrivateKey, does it need to be a new type? could it be an extension trait for secp256k1::SecretKey instead? It looks to me like the compressed flag only ever gets used in fmt_wif() 06:07 < andytoshi> yes it needs to be o new type 06:07 < andytoshi> it has a network and a compressedness flag 06:07 < andytoshi> yes, we could make people carry tuples around and pass them to fmt_wif and get them out of from_str 06:08 < andytoshi> yancy: well you can blame satoshi for defining an address serialization with a network, a privkey serialization with a network, but no pubkey serialization with a network 06:08 < andytoshi> if you don't like it you can use xkeys 06:08 < Ademan> I guess it makes sense to have the type for the serde de/serialization, but everywhere else, wif formatting is only something you care about at the very edges of your application 06:08 < andytoshi> Ademan: the compressedness flag is used when computing public keys 06:09 < Ademan> it is? I missed that... 06:09 < andytoshi> lol it had better be, its entire meaning is about public keys 06:09 < Ademan> ah, hahaha, right that makes sense, sorry, only halfway through the morning coffee 06:10 < andytoshi> i mean, we might have messed up lol 06:10 < andytoshi> no, we didn't https://docs.rs/bitcoin/latest/src/bitcoin/crypto/key.rs.html#431-436 06:11 < andytoshi> re yancy's original suggestion -- generate an address and a privkey as a pair, since they both have networks, that's interesting 06:11 < andytoshi> it's kinda annoying because there are like 4 address types that have pubkeys in them 06:11 < andytoshi> without even considering descriptors 06:13 < Ademan> yeah, honestly the comment on compressed is confusing "Whether this private key should be serialized as compressed." I'm going to blame that for me being an idiot 06:14 < Ademan> "Whether or not this private key corresponds to a compressed public key." ? I don't see that it has any other use besides being de/serialized into WIF 06:16 < andytoshi> yea, i think that comment would've been copied from something about public keys 06:17 < andytoshi> we can definitley improve it 06:37 < yancy> I was just surprised that this prints different results: println!("{} {}", PrivateKey::new(secret_key, Network::Testnet), PrivateKey::new(secret_key, Network::Bitcoin)); 06:38 < yancy> and reading over the docs didn't help me understand why that was the case, or why network is associated with privatekey 06:40 < yancy> just felt I woudl be remiss to not mention it 06:41 < yancy> cause somebody may make a mistake that matters heh 10:02 -!- greypw1495085720 [~greypw@user/greypw] has quit [Ping timeout: 272 seconds] 14:22 -!- jerryf [~jerryf@user/jerryf] has quit [Remote host closed the connection] 14:22 -!- jerryf [~jerryf@user/jerryf] has joined #bitcoin-rust 17:44 -!- Netsplit *.net <-> *.split quits: laanwj, BlueMattMtrxBot, tnull[m] 17:51 -!- Netsplit over, joins: laanwj, BlueMattMtrxBot, tnull[m] 17:54 -!- luisschwab [~luisschwa@vmi2753007.contaboserver.net] has joined #bitcoin-rust 17:56 -!- luisschwab_ [~luisschwa@vmi2753007.contaboserver.net] has quit [Ping timeout: 256 seconds] 17:56 -!- darosior [~darosior@109.205.214.46] has quit [Ping timeout: 256 seconds] 18:37 -!- jerryf [~jerryf@user/jerryf] has quit [Ping timeout: 272 seconds] 18:50 -!- jerryf [~jerryf@user/jerryf] has joined #bitcoin-rust 22:37 -!- jerryf [~jerryf@user/jerryf] has quit [Remote host closed the connection] 22:37 -!- jerryf [~jerryf@user/jerryf] has joined #bitcoin-rust --- Log closed Sat Nov 01 00:00:25 2025