Module: Baseh::Profiles

Defined in:
lib/baseh/profiles.rb

Overview

Frozen tier profiles. Each is built from the full alphanumeric set with cumulative visual and spoken strips; the spoken strips interact with the visual ones exactly as the web tools derive them, so the tool capacities match.

Minimum  36 symbols, no checksum, XXX-XXX      2,176,782,336 ids
Light    31 symbols, 2 checksums, XXXX-XXXX      887,503,681 ids
Medium   28 symbols, 2 checksums, XXXX-XXXX      481,890,304 ids (default)
Heavy    26 symbols, 2 checksums, XXXX-XXXX      308,915,776 ids

All four keep the typed O/I/L aliases where possible, use a hyphen delimiter at the midpoint and run the default profanity blocklist. Every tier permutes with the frozen published key (FROZEN_KEY_BYTES below): the key is public, so the permutation obscures sequence but is not secrecy. The -p variants are identical but permute with caller-supplied key material instead.

Constant Summary collapse

OIL_ALIASES =
{ "O" => "0", "I" => "1", "L" => "1" }.freeze
FROZEN_KEY_BYTES =

The frozen published permutation key. Public by design: it makes issued codes look non-sequential but offers no secrecy, since anyone can read it here. Never swap it on a live namespace; codes only decode with the key they were issued under. Use the -p variants to supply private key material.

"baseh-frozen-key-v1".b.freeze
TIERS =

Tier shapes shared by the plain and (-p) keyed helpers. The values are thawed on every build, so each helper returns a fresh mutable profile.

{
  minimum: {
    profile_id: "baseh-minimum",
    body_alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
    checksum_alphabet: "",
    checksum_length: 0,
    separator: "-",
    grouping: [3, 3],
    aliases: {}
  },
  light: {
    profile_id: "baseh-light",
    body_alphabet: "0123456789ABCEFGHJKMNPQRSUVWXYZ",
    checksum_alphabet: "234679ACEFGHJKMNPQRUVWXY",
    checksum_length: 2,
    separator: "-",
    grouping: [4, 4],
    aliases: { **OIL_ALIASES, "D" => "B", "T" => "P" }
  },
  medium: {
    profile_id: "baseh-medium",
    body_alphabet: "0123456789ACDEFGHJKMPQRUVXYZ",
    checksum_alphabet: "234679ACDEFGHJKMPQRUVXY",
    checksum_length: 2,
    separator: "-",
    grouping: [4, 4],
    # B and S are dropped for looking like 8 and 5; since they can never
    # be issued, a typed B is always an 8 and a typed S always a 5.
    aliases: { **OIL_ALIASES, "B" => "8", "S" => "5", "T" => "P",
               "N" => "M", "W" => "V" }
  },
  heavy: {
    profile_id: "baseh-heavy",
    body_alphabet: "0123456789ABCEFHJKMPQRVXYZ",
    checksum_alphabet: "234679ACEFHJKMPQRUVXY",
    checksum_length: 2,
    separator: "-",
    grouping: [4, 4],
    aliases: { **OIL_ALIASES, "D" => "B", "T" => "P", "N" => "M",
               "W" => "V", "S" => "F", "G" => "C" }
  }
}.freeze
EXPANDABLE_BODY =

Spec 17.1. The expandable recommended default carries the same safety posture as baseh-medium-v1: the medium visual strips (O, I, L, B, S) and the medium spoken strips (T, N, W), so an issued code never emits a visual or spoken confusable. The zero ban of section 19.2 then removes 0 (and O, already gone), leaving a 27-symbol body. The checksum alphabet derives as "0" plus the body (28 symbols).

"123456789ACDEFGHJKMPQRUVXYZ"

Class Method Summary collapse

Class Method Details

.baseh_expandable_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-expandable permuted with caller-supplied key material.



147
148
149
# File 'lib/baseh/profiles.rb', line 147

def baseh_expandable_p_v1(key_bytes:, key_id: "default", rounds: 8)
  expandable_tier(keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_expandable_v1Object

The frozen expandable tier; the recommended starting point for new namespaces. Four characters while the namespace is small, gaining one symbol automatically as issuance climbs past each generation's capacity. The body alphabet is the medium safety set (the full alphanumeric set minus the visual look-alikes O, I, L, B, S and the spoken-confusable T, N, W), with the zero ban of spec 19.2 removing 0 (27 symbols); the checksum alphabet derives as "0" plus the body (28 symbols). The short checksum of spec 22 is on: one checksum symbol through five characters (27^3 = 19,683 ids at length 4, 27^4 = 531,441 at length 5), two from six characters up. The hyphen appears from six characters up, split by the balanced grouping rule of spec 19.5.



142
143
144
# File 'lib/baseh/profiles.rb', line 142

def baseh_expandable_v1
  expandable_tier(frozen_permutation, false)
end

.baseh_heavy_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-heavy permuted with caller-supplied key material.



119
120
121
# File 'lib/baseh/profiles.rb', line 119

def baseh_heavy_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:heavy, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_heavy_v1Object

Conservative alphabet plus spoken heavy, two checksum symbols, hyphen-delimited.



114
115
116
# File 'lib/baseh/profiles.rb', line 114

def baseh_heavy_v1
  tier(:heavy, frozen_permutation, false)
end

.baseh_light_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-light permuted with caller-supplied key material.



99
100
101
# File 'lib/baseh/profiles.rb', line 99

def baseh_light_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:light, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_light_v1Object

Visual light plus spoken light, two checksum symbols, hyphen-delimited.



94
95
96
# File 'lib/baseh/profiles.rb', line 94

def baseh_light_v1
  tier(:light, frozen_permutation, false)
end

.baseh_medium_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-medium permuted with caller-supplied key material.



109
110
111
# File 'lib/baseh/profiles.rb', line 109

def baseh_medium_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:medium, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_medium_v1Object

Visual medium plus spoken medium, two checksum symbols, hyphen-delimited. The default.



104
105
106
# File 'lib/baseh/profiles.rb', line 104

def baseh_medium_v1
  tier(:medium, frozen_permutation, false)
end

.baseh_minimum_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-minimum permuted with caller-supplied key material.



89
90
91
# File 'lib/baseh/profiles.rb', line 89

def baseh_minimum_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:minimum, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_minimum_v1Object

Alphanumeric, no safety strips, no checksum, hyphen-delimited XXX-XXX.



84
85
86
# File 'lib/baseh/profiles.rb', line 84

def baseh_minimum_v1
  tier(:minimum, frozen_permutation, false)
end