contributed by <Yuessiah
, HexRabbit
[1]>
vonchuang
關於 Radix Econemy 早有引用的文章連結了,想要更詳盡的定義直接點開看即可。
"Yuessiah"
Balanced ternary 是個特別的三進制數字系統,
其一個位置稱作 trit,一個 trit 有
符號
符號
符號
Perhaps the prettiest number system of all… is the balanced ternary notation
— Donald Knuth, The Art of Programming
數字與中文字間記得也要用空白隔開!
課程助教好ㄛ
Yuessiah
操作與其他整數進制系統到 10 進制一樣
例如:
例如:
將整數與小數分離
整數部
由餘數部份得知整數部為
小數部
由整數部份得知小數部為
由維基百科[2]上知道第一位為
使用同樣的思考方式,也能引出比大小的運算
tryte 就如同 byte 表達的意義
1 byte 為一組 8 bits
而 1 tryte 則沒有一個統一的標準 (不過還是有這樣的詞😕
根據定義[3]
對
可得知在扣除易於表達( 2 進制)的特性,3 進制系統在資訊傳遞上是優於其他整數進制的,因為整數集合中 3 最接近 e
├───┐ 每一突出代表一 3 的 n 次方, 且為正數
│ │ 從正下方開始 n=0,逆時針一圈數過去,兩相鄰突出相差 1, 後數的大於前一數
└───┘ 例如左圖為 3^3
┌┬──┐ 與突出相似,但內縮為負數
│ │ 例如左圖為 -3^3
└───┘
├─┴─┤ 仔細觀察可知,一根突出的線可代表一個累加次方
┤ ├ 共有 8 根,於是計算出最大上界為 (3^8-1)/2
├─┬─┤ 式子意義:可類比成將 8 個位置的普通三進制數全部填 1 (i.e. 11111111)
詳細閱讀程式碼後發現有個地方不太尋常
digit[SZD] = {
{ 32, 3 },
{ 26, 6 },
{ 16, 8 },
{ 0, 6 },
{ 6, 3 },
{ 9, 7 },
{ 21, 5 },
{ 35, 7 }
};
把 len 加一加,理論上要得到 42,卻得到了 45
為了方便除錯,把 pat 裡面的值都印出來
i = 0, {-30, -108, -116}
i = 3, {-30, -108, -128}
i = 6, {-30, -108, -128}
i = 9, {-30, -108, -128}
i = 12, {-30, -108, -112}
i = 15, {10}
i = 16, {-30, -108, -126}
i = 19, {32}
i = 20, {32}
i = 21, {32}
i = 22, {-30, -108, -126}
i = 25, {10}
i = 26, {-30, -108, -108}
i = 29, {-30, -108, -128}
i = 32, {-30, -108, -128}
i = 35, {-30, -108, -128}
i = 38, {-30, -108, -104}
i = 41, {10}
---
i = 0, {-30, -108, -100}
i = 3, {-30, -108, -128}
i = 6, {-30, -108, -76}
i = 9, {-30, -108, -128}
i = 12, {-30, -108, -92}
i = 15, {10}
i = 16, {-30, -108, -92}
i = 19, {32}
i = 20, {32}
i = 21, {32}
i = 22, {-30, -108, -100}
i = 25, {10}
i = 26, {-30, -108, -100}
i = 29, {-30, -108, -128}
i = 32, {-30, -108, -84}
i = 35, {-30, -108, -128}
i = 38, {-30, -108, -92}
i = 41, {10}
---
i = 0, {-30, -108, -116}
i = 3, {-30, -108, -84}
i = 6, {-30, -108, -84}
i = 9, {-30, -108, -84}
i = 12, {-30, -108, -112}
i = 15, {10}
i = 16, {-30, -108, -100}
i = 19, {32}
i = 20, {32}
i = 21, {32}
i = 22, {-30, -108, -92}
i = 25, {10}
i = 26, {-30, -108, -108}
i = 29, {-30, -108, -76}
i = 32, {-30, -108, -76}
i = 35, {-30, -108, -76}
i = 38, {-30, -108, -104}
i = 41, {10}
可以發現digit[2]
有些小問題
如果 len 為 8,那麼在/* Show the result. */
會把i = 22
後前兩個字元也複製下,
len 改成 5 或許比較合理。
不過因為/* Show the result. */
這邊是從 0 到 SZD-1,貌似結果上不會產生問題(?
k3b
程式需要做哪些更動,才符合期望呢?IOTA 的加密並非基於 ECC[5],而是使用一個基於三進制 hash function,名為 Curl
Curl 可以防止量子電腦[6]破解密碼。
As IOTA was the first distributed ledger project that took the inevitable threat of scalable quantum computers seriously, we had to move away from standard elliptic curve cryptography. A few months later NSA validated our concerns by announcing official concern over the ‘quantum threat’. Since then there has been numerous quantum leaps in quantum computing, further validating this engineering decision we made. Beyond this concern we also had to follow a path that is optimized for the future landscape of Internet of Things. Curl is a new kind of hash function optimized precisely for these two things, it is based on well-studied sponge construction invented by the Keccak creators (SHA-3) and strictly conforms to all requirements described in their official paper. [7]