Vanitygen for Grin

Hello everyone! I am new to both Grin & Rust and I wanted to get my hands dirty by playing around with some of its Rust libraries. So I created a small project which is a vanity address generator for Grin. It essentially allows you to generate grin addresses with a custom prefix of your choice. Let me know what you think. Any feedback is appreciated. Thanks!

13 Likes

Excellent. Must it be derived by seed rather than raw public key because we don’t have a way to load raw keys into current wallets?

I would enjoy having deterministic wallets (e.g. passphrase “igno” > hash/etc. > private key) but my knowledge is very basic and I don’t know how to do it without being able to load a private key directly.

1 Like

If you take a look at my code (its only 100ish lines of code) I do have some commented out code that derives a slatepack address from a raw public key. Its significantly faster although I am not sure how it can be used in real wallets. From the quick research that I did, all major wallets seem to be HD only.

Coding up your brain wallet idea would be straightforward, but I am not sure how you would use that private key easily.

1 Like

Very cool! I love it.

3 Likes

Cool project :sunglasses:.
Perhaps the trick is to derive the slatepack address at the account level.
Key derived in a HD wallet is purpose’ / coin_type’ / account’ / change / address_index
If you derive the slate-pack address at the account level, iterate over the account number, it should be much faster. I think that is currently what grin++ does. Perhaps @davidtavarez know better since he implemented the ability to derive a new slate-pack address with the same mnemonic). you can iterate over the account level, only generate that public key and its corresponding slate-pack address. That should give you the 1000x increase in speed since you only need to change the account index and derive the new public key.

The only downside of this approach is that you have to know the account number to restore a certain vanity address. If you only write down the mnemonic, it would require you to rerun all the iterations to find back your address and corresponding account number upon a wallet restore.

3 Likes

That sounds cool but I don’t see any wallet implementing this. Most users would expect to enter their seed and have the pattern “out of the box”. But I could implement it if people want it.

1 Like

For now it is not worth it. @davidtavarez How did you implement the generate new slate-pack address function in Grin++, by changing the derivation to a new account, or using another way? If so, is that information also stored in the wallet file?

2 Likes

Here’s how I did it on Grin++

/* 
        *  From RFC-0010 (https://github.com/mimblewimble/grin-rfcs/blob/master/text/0010-online-transacting-via-tor.md):
        * 
        *  Although ed25519 is a different curve than used by the grin protocol, we can still use our HD wallets to 
        *  generate deterministic ed25519 public keys (and therefore Grin addresses). For account m/0, addresses will be 
        *  generated using keychain paths m/0/1/x, for account m/1, addresses will be generated using m/1/1/x, etc. To 
        *  generate addresses for a keychain path, we derive the private key in the usual way, but then blake2b hash the 
        *  derived key to get the ed25519 secret key, which can then be used to calculate the public key and address.
        * 
        */
3 Likes

@makis Added a link to you vanity address generator on:

1 Like