POP-0101: PoWMEM
Alternative Profile scheme for minimalists
Live demo: https://telamon.github.io/powmem/demo.html
We think the demo is kinda cool cause if you'd build it using traditional Web 2.0 tech you would not be able to
provide a form and a realtime world-map with 0
server-costs.
Install
$ npm i powmem
API
roll(A, S, L)
Generate Identity Use this to provide an alternative to user registrations.
Requires peer dependency
@noble/curves
Callsignature:
roll(
age: number, // 0: 16+, 1: 24+, 2: 32+, 3: 48+
sex: number: // 0: Female, 1: Male, 2: Non-binary, 3: Robot
location: string, // A geohash
geobits: number, // target precision, default: 15 (bits)
maxTries: number, // Give up and return undefined, default: 50 000 attempts.
) Uint8Array? // returns mined Secret
Example:
import { roll } from 'powmem'
const secret = roll(2, 1, 'h4x')
console.log('Your secret key is', secret)
Imagine a nation where every citizen born takes a crayon and draws their own legal passport.
decodeASL(key)
Decode Identity Decodes the burnt in information:
Callsignature:
decodeASL(
key: Uint8Array|hexstring
) ASL : {
age: number, // 0..3
sex: number, // 0..3
location: string // 3-5 characters of geohash.
}
Example:
import { decodeASL, flagOf } from 'powmem'
import Geohash from 'latlon-geohash'
const key = '0149170fe78b061ce6c7295fff2daa303f710ba17efd8fafd8343292b4295e84'
const { age, sex, location } = decodeASL(key)
const humanYears = [16, 24, 32, 48][age]
console.log('Age:', humanYears)
console.log('Sex:', sex)
console.log('Country:', flagOf(location))
console.log('Coordinates:', Geohash.decode(location, 3))
Produces:
Produces:
Age: 24
Sex: 0
Country: 🇲🇫
Coordinates: { lat: -75.2, lon: 10.5 }
JSDOC output
Functions
-
roll(age, sex, location, [geobits], [maxTries]) ⇒
Uint8Array
-
Rolls keypairs until a matching public-key is found
-
decodeASL(publicKey, geobits) ⇒
ASL
-
Holistically decodes ASL from a public key
-
unpackGeo(buf, nBits) ⇒
string
-
Unpacks bitarray back into base32 string
-
packGeo(str, [nBits], destination) ⇒
Uint8Array
-
Bitpacks a geohash string containing quintets to arbitrary bit-precision 'u120fw' <-- contains 30bits accurate to ~1.2 Kilometers References: Format specification: https://en.m.wikipedia.org/wiki/Geohash Bitdepthchart: https://www.ibm.com/docs/en/streams/4.3.0?topic=334-geohashes
-
shift(x, inp) ⇒
number
-
Treats buffer as a series of latched 8bit shift-registers shifts all bits 1 step from low to high.
-
unshift(x, inp) ⇒
number
-
Opposite of shift, shifts all bits 1 step towards low.
-
xorDistance(a, b) ⇒
number
-
Calculates XOR-Distance between two buffers
-
flagOf(geohash, [bits]) ⇒
string
-
Returns nearest flag of geohash. The coordinates were given by GPT.
Typedefs
Uint8Array
roll(age, sex, location, [geobits], [maxTries]) ⇒ Rolls keypairs until a matching public-key is found
Kind: global function
Returns: Uint8Array
- secret key if found within maxTries, null otherwise
Param | Type | Description |
---|---|---|
age |
0 | 1 | 2 | 3
|
values: 0: 16+, 1: 24+; 2: 32+; 3: 40+ |
sex |
0 | 1 | 2 | 3
|
values: 0: Female, 1: Male, 2: Nonbinary, 3: Bot |
location | string |
a geohash |
[geobits] | number |
geohash bit-size; default: 15 |
[maxTries] | number |
maximum number of rolls before giving up. |
ASL
decodeASL(publicKey, geobits) ⇒ Holistically decodes ASL from a public key
Kind: global function
Param | Type | Description |
---|---|---|
publicKey |
Uint8Array | hexstring
|
|
geobits | number |
geohash bit-size; default: 15 |
string
unpackGeo(buf, nBits) ⇒ Unpacks bitarray back into base32 string
Kind: global function
Returns: string
- A geohash
Param | Type | Description |
---|---|---|
buf |
Uint8Array | Buffer | array
|
a byte array |
nBits | number |
number of bits to unpack |
Uint8Array
packGeo(str, [nBits], destination) ⇒ Bitpacks a geohash string containing quintets to arbitrary bit-precision 'u120fw' <-- contains 30bits accurate to ~1.2 Kilometers References: Format specification: https://en.m.wikipedia.org/wiki/Geohash Bitdepthchart: https://www.ibm.com/docs/en/streams/4.3.0?topic=334-geohashes
q1 q2 q3 18 19
HASH 01101 11111 11000 001|00 00010
LON 0 1 1 1 1 1 0 0 0 |0 0 0 0
LAT 1 0 1 1 1 1 0 0 1| 0 0 1
Kind: global function
Returns: Uint8Array
- buffer containing binary geohash
Param | Type | Description |
---|---|---|
str | string |
A geohash string. |
[nBits] | number |
precision in bits; default 12 |
destination |
Uint8Array | Buffer | Array
|
buffer |
number
shift(x, inp) ⇒ Treats buffer as a series of latched 8bit shift-registers shifts all bits 1 step from low to high.
Kind: global function
Returns: number
- the previous last bit
Param | Type | Description |
---|---|---|
x | bit |
The value to shift in |
inp |
Uint8Array | Buffer | array
|
The input buffer |
number
unshift(x, inp) ⇒ Opposite of shift, shifts all bits 1 step towards low.
Kind: global function
Returns: number
- the previous first bit
Param | Type | Description |
---|---|---|
x | bit |
The value to shift out |
inp |
Uint8Array | Buffer | array
|
The input buffer |
number
xorDistance(a, b) ⇒ Calculates XOR-Distance between two buffers
Kind: global function
Returns: number
- Distance
Param | Type | Description |
---|---|---|
a |
Uint8Array | Buffer | Array
|
Buffer A |
b |
Uint8Array | Buffer | Array
|
Buffer B |
string
flagOf(geohash, [bits]) ⇒ Returns nearest flag of geohash. The coordinates were given by GPT.
Kind: global function
Returns: string
- Emoji Flag
Param | Type | Description |
---|---|---|
geohash | string |
A hashed location |
[bits] | number |
Geohash bit precision |
0
| 1
bit :
string
hexstring :
Object
ASL : Kind: global typedef
License
AGPLv3 - or mit or whatever, implement your own, it was kinda fun :-)