%global _empty_manifest_terminate_build 0
Name: python-mkm
Version: 0.12.6
Release: 1
Summary: A common identity module
License: MIT
URL: https://github.com/dimchat/mkm-py
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/34/90/33bd7c2c7263fcfd89a14e1253a13004166eda2c845fac8ab13f4de233b4/mkm-0.12.6.tar.gz
BuildArch: noarch
%description
# Ming Ke Ming (名可名) -- Account Module (Python)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/mkm-py/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/alpha-0.10.12-red.svg)](https://github.com/dimchat/mkm-py/wiki)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/mkm-py/pulls)
[![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/mkm-py/wiki)
This [document](https://github.com/moky/DIMP/blob/master/MingKeMing-Identity.md) introduces a common **Account Module** for decentralized user identity authentication.
Copyright © 2018-2019 Albert Moky
- [Meta](#meta)
- [Type](#meta-type)
- [Key](#meta-key)
- [Seed](#meta-seed)
- [Fingerprint](#meta-fingerprint)
- [ID](#id)
- [Type](#id-type)
- [Name](#id-name)
- [Address](#id-address)
- [Terminal](#id-terminal)
- [Samples](#samples)
## 0. Meta
The **Meta** was generated by your **private key**, it can be used to build a new ID for entity, or verify the ID/PK pair.
It consists of 4 fields:
| Field | Description |
| ----------- | ----------------------------- |
| type | Meta Algorithm Version |
| key | Public Key |
| seed | Entity Name |
| fingerprint | Signature to generate address |
### 0.0. Meta Type
* ```0x01``` **Default version**
* ```0x02``` BTC version
* ```0x03``` Extended BTC version
* ```0x04``` ETH version
* ```0x05``` Extended ETH version
### 0.1. Key
A **public key** (PK) was bound to an ID by the **Meta Algorithm**.
### 0.2. Seed
A string as same as **ID.name** for generate the fingerprint.
### 0.3. Fingerprint
THe **fingerprint** field was generated by your **private key** and **seed**:
````python
data = seed.encode('utf-8')
fingerprint = private_key.sign(data)
````
## 1. ID
The **ID** is used to identify an **entity**(user/group). It consists of 3 fields and 2 extended properties:
| Field | Description |
| ----------- | ----------------------------- |
| name | Same with meta.seed |
| address | Unique Identification |
| terminal | Login point, it's optional. |
| type | Network type |
The ID format is ```name@address[/terminal]```.
### 1.0. ID Type
The **network type** of a person is ```8```, and group is ```16```:
```python
class NetworkType(IntEnum):
# Person Account
MAIN = 0x08 # 0000 1000 (Person)
# Virtual Groups
GROUP = 0x10 # 0001 0000 (Multi-Persons)
POLYLOGUE = 0x10 # 0001 0000 (Multi-Persons Chat, N < 100)
CHATROOM = 0x30 # 0011 0000 (Multi-Persons Chat, N >= 100)
# Network
PROVIDER = 0x76 # 0111 0110 (Service Provider)
STATION = 0x88 # 1000 1000 (Server Node)
# Internet of Things
THING = 0x80 # 1000 0000 (IoT)
ROBOT = 0xC8 # 1100 1000
```
### 1.1. Name
The **Name** field is a username, or just a random string for group:
1. The length of name must more than 1 byte, less than 32 bytes;
2. It should be composed by a-z, A-Z, 0-9, or charactors '_', '-', '.';
3. It cannot contain key charactors('@', '/').
```python
# Name examples
user_name = "Albert.Moky"
group_name = "Group-9527"
```
### 1.2. Address
The **Address** field was created with the **Fingerprint** in Meta and a **Network ID**:
```python
def check_code(data: bytes) -> bytes:
# check code in BTC address
return sha256(sha256(data))[:4]
class BTCAddress(Address):
@classmethod
def new(cls, data: bytes, network: NetworkType=0) -> Address:
"""Generate address with fingerprint and network ID
:param data: fingerprint (signature/key.data)
:param network: address type
:return: Address object
"""
prefix = chr(network).encode('latin1')
digest = ripemd160(sha256(data))
code = check_code(prefix + digest)
address = base58_encode(prefix + digest + code)
return BTCAddress(address)
```
When you get a meta for the entity ID from the network,
you must verify it with the consensus algorithm before accept its **public key**.
### 1.3. Terminal
A resource identifier as **Login Point**.
## 2. Samples
### ID
```python
# ID examples
ID1 = "hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj" # Immortal Hulk
ID2 = "moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk" # Monkey King
```
### Meta
```javascript
/* Meta(JsON) for hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj */
{
"version" : 0x01,
"key" : {
"algorithm" : "RSA",
"data" : "-----BEGIN PUBLIC KEY-----\nMIGJAoGBALB+vbUK48UU9rjlgnohQowME+3JtTb2hLPqtatVOW364/EKFq0/PSdnZVE9V2Zq+pbX7dj3nCS4pWnYf40ELH8wuDm0Tc4jQ70v4LgAcdy3JGTnWUGiCsY+0Z8kNzRkm3FJid592FL7ryzfvIzB9bjg8U2JqlyCVAyUYEnKv4lDAgMBAAE=\n-----END PUBLIC KEY-----",
// other parameters
"mode" : "ECB",
"padding" : "PKCS1",
"digest" : "SHA256"
},
"seed" : "hulk",
"fingerprint" : "jIPGWpWSbR/DQH6ol3t9DSFkYroVHQDvtbJErmFztMUP2DgRrRSNWuoKY5Y26qL38wfXJQXjYiWqNWKQmQe/gK8M8NkU7lRwm+2nh9wSBYV6Q4WXsCboKbnM0+HVn9Vdfp21hMMGrxTX1pBPRbi0567ZjNQC8ffdW2WvQSoec2I="
}
```
(All data encode with **BASE64** algorithm as default, excepts the **address**)
%package -n python3-mkm
Summary: A common identity module
Provides: python-mkm
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-mkm
# Ming Ke Ming (名可名) -- Account Module (Python)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/mkm-py/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/alpha-0.10.12-red.svg)](https://github.com/dimchat/mkm-py/wiki)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/mkm-py/pulls)
[![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/mkm-py/wiki)
This [document](https://github.com/moky/DIMP/blob/master/MingKeMing-Identity.md) introduces a common **Account Module** for decentralized user identity authentication.
Copyright © 2018-2019 Albert Moky
- [Meta](#meta)
- [Type](#meta-type)
- [Key](#meta-key)
- [Seed](#meta-seed)
- [Fingerprint](#meta-fingerprint)
- [ID](#id)
- [Type](#id-type)
- [Name](#id-name)
- [Address](#id-address)
- [Terminal](#id-terminal)
- [Samples](#samples)
## 0. Meta
The **Meta** was generated by your **private key**, it can be used to build a new ID for entity, or verify the ID/PK pair.
It consists of 4 fields:
| Field | Description |
| ----------- | ----------------------------- |
| type | Meta Algorithm Version |
| key | Public Key |
| seed | Entity Name |
| fingerprint | Signature to generate address |
### 0.0. Meta Type
* ```0x01``` **Default version**
* ```0x02``` BTC version
* ```0x03``` Extended BTC version
* ```0x04``` ETH version
* ```0x05``` Extended ETH version
### 0.1. Key
A **public key** (PK) was bound to an ID by the **Meta Algorithm**.
### 0.2. Seed
A string as same as **ID.name** for generate the fingerprint.
### 0.3. Fingerprint
THe **fingerprint** field was generated by your **private key** and **seed**:
````python
data = seed.encode('utf-8')
fingerprint = private_key.sign(data)
````
## 1. ID
The **ID** is used to identify an **entity**(user/group). It consists of 3 fields and 2 extended properties:
| Field | Description |
| ----------- | ----------------------------- |
| name | Same with meta.seed |
| address | Unique Identification |
| terminal | Login point, it's optional. |
| type | Network type |
The ID format is ```name@address[/terminal]```.
### 1.0. ID Type
The **network type** of a person is ```8```, and group is ```16```:
```python
class NetworkType(IntEnum):
# Person Account
MAIN = 0x08 # 0000 1000 (Person)
# Virtual Groups
GROUP = 0x10 # 0001 0000 (Multi-Persons)
POLYLOGUE = 0x10 # 0001 0000 (Multi-Persons Chat, N < 100)
CHATROOM = 0x30 # 0011 0000 (Multi-Persons Chat, N >= 100)
# Network
PROVIDER = 0x76 # 0111 0110 (Service Provider)
STATION = 0x88 # 1000 1000 (Server Node)
# Internet of Things
THING = 0x80 # 1000 0000 (IoT)
ROBOT = 0xC8 # 1100 1000
```
### 1.1. Name
The **Name** field is a username, or just a random string for group:
1. The length of name must more than 1 byte, less than 32 bytes;
2. It should be composed by a-z, A-Z, 0-9, or charactors '_', '-', '.';
3. It cannot contain key charactors('@', '/').
```python
# Name examples
user_name = "Albert.Moky"
group_name = "Group-9527"
```
### 1.2. Address
The **Address** field was created with the **Fingerprint** in Meta and a **Network ID**:
```python
def check_code(data: bytes) -> bytes:
# check code in BTC address
return sha256(sha256(data))[:4]
class BTCAddress(Address):
@classmethod
def new(cls, data: bytes, network: NetworkType=0) -> Address:
"""Generate address with fingerprint and network ID
:param data: fingerprint (signature/key.data)
:param network: address type
:return: Address object
"""
prefix = chr(network).encode('latin1')
digest = ripemd160(sha256(data))
code = check_code(prefix + digest)
address = base58_encode(prefix + digest + code)
return BTCAddress(address)
```
When you get a meta for the entity ID from the network,
you must verify it with the consensus algorithm before accept its **public key**.
### 1.3. Terminal
A resource identifier as **Login Point**.
## 2. Samples
### ID
```python
# ID examples
ID1 = "hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj" # Immortal Hulk
ID2 = "moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk" # Monkey King
```
### Meta
```javascript
/* Meta(JsON) for hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj */
{
"version" : 0x01,
"key" : {
"algorithm" : "RSA",
"data" : "-----BEGIN PUBLIC KEY-----\nMIGJAoGBALB+vbUK48UU9rjlgnohQowME+3JtTb2hLPqtatVOW364/EKFq0/PSdnZVE9V2Zq+pbX7dj3nCS4pWnYf40ELH8wuDm0Tc4jQ70v4LgAcdy3JGTnWUGiCsY+0Z8kNzRkm3FJid592FL7ryzfvIzB9bjg8U2JqlyCVAyUYEnKv4lDAgMBAAE=\n-----END PUBLIC KEY-----",
// other parameters
"mode" : "ECB",
"padding" : "PKCS1",
"digest" : "SHA256"
},
"seed" : "hulk",
"fingerprint" : "jIPGWpWSbR/DQH6ol3t9DSFkYroVHQDvtbJErmFztMUP2DgRrRSNWuoKY5Y26qL38wfXJQXjYiWqNWKQmQe/gK8M8NkU7lRwm+2nh9wSBYV6Q4WXsCboKbnM0+HVn9Vdfp21hMMGrxTX1pBPRbi0567ZjNQC8ffdW2WvQSoec2I="
}
```
(All data encode with **BASE64** algorithm as default, excepts the **address**)
%package help
Summary: Development documents and examples for mkm
Provides: python3-mkm-doc
%description help
# Ming Ke Ming (名可名) -- Account Module (Python)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/dimchat/mkm-py/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/alpha-0.10.12-red.svg)](https://github.com/dimchat/mkm-py/wiki)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/mkm-py/pulls)
[![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/mkm-py/wiki)
This [document](https://github.com/moky/DIMP/blob/master/MingKeMing-Identity.md) introduces a common **Account Module** for decentralized user identity authentication.
Copyright © 2018-2019 Albert Moky
- [Meta](#meta)
- [Type](#meta-type)
- [Key](#meta-key)
- [Seed](#meta-seed)
- [Fingerprint](#meta-fingerprint)
- [ID](#id)
- [Type](#id-type)
- [Name](#id-name)
- [Address](#id-address)
- [Terminal](#id-terminal)
- [Samples](#samples)
## 0. Meta
The **Meta** was generated by your **private key**, it can be used to build a new ID for entity, or verify the ID/PK pair.
It consists of 4 fields:
| Field | Description |
| ----------- | ----------------------------- |
| type | Meta Algorithm Version |
| key | Public Key |
| seed | Entity Name |
| fingerprint | Signature to generate address |
### 0.0. Meta Type
* ```0x01``` **Default version**
* ```0x02``` BTC version
* ```0x03``` Extended BTC version
* ```0x04``` ETH version
* ```0x05``` Extended ETH version
### 0.1. Key
A **public key** (PK) was bound to an ID by the **Meta Algorithm**.
### 0.2. Seed
A string as same as **ID.name** for generate the fingerprint.
### 0.3. Fingerprint
THe **fingerprint** field was generated by your **private key** and **seed**:
````python
data = seed.encode('utf-8')
fingerprint = private_key.sign(data)
````
## 1. ID
The **ID** is used to identify an **entity**(user/group). It consists of 3 fields and 2 extended properties:
| Field | Description |
| ----------- | ----------------------------- |
| name | Same with meta.seed |
| address | Unique Identification |
| terminal | Login point, it's optional. |
| type | Network type |
The ID format is ```name@address[/terminal]```.
### 1.0. ID Type
The **network type** of a person is ```8```, and group is ```16```:
```python
class NetworkType(IntEnum):
# Person Account
MAIN = 0x08 # 0000 1000 (Person)
# Virtual Groups
GROUP = 0x10 # 0001 0000 (Multi-Persons)
POLYLOGUE = 0x10 # 0001 0000 (Multi-Persons Chat, N < 100)
CHATROOM = 0x30 # 0011 0000 (Multi-Persons Chat, N >= 100)
# Network
PROVIDER = 0x76 # 0111 0110 (Service Provider)
STATION = 0x88 # 1000 1000 (Server Node)
# Internet of Things
THING = 0x80 # 1000 0000 (IoT)
ROBOT = 0xC8 # 1100 1000
```
### 1.1. Name
The **Name** field is a username, or just a random string for group:
1. The length of name must more than 1 byte, less than 32 bytes;
2. It should be composed by a-z, A-Z, 0-9, or charactors '_', '-', '.';
3. It cannot contain key charactors('@', '/').
```python
# Name examples
user_name = "Albert.Moky"
group_name = "Group-9527"
```
### 1.2. Address
The **Address** field was created with the **Fingerprint** in Meta and a **Network ID**:
```python
def check_code(data: bytes) -> bytes:
# check code in BTC address
return sha256(sha256(data))[:4]
class BTCAddress(Address):
@classmethod
def new(cls, data: bytes, network: NetworkType=0) -> Address:
"""Generate address with fingerprint and network ID
:param data: fingerprint (signature/key.data)
:param network: address type
:return: Address object
"""
prefix = chr(network).encode('latin1')
digest = ripemd160(sha256(data))
code = check_code(prefix + digest)
address = base58_encode(prefix + digest + code)
return BTCAddress(address)
```
When you get a meta for the entity ID from the network,
you must verify it with the consensus algorithm before accept its **public key**.
### 1.3. Terminal
A resource identifier as **Login Point**.
## 2. Samples
### ID
```python
# ID examples
ID1 = "hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj" # Immortal Hulk
ID2 = "moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk" # Monkey King
```
### Meta
```javascript
/* Meta(JsON) for hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj */
{
"version" : 0x01,
"key" : {
"algorithm" : "RSA",
"data" : "-----BEGIN PUBLIC KEY-----\nMIGJAoGBALB+vbUK48UU9rjlgnohQowME+3JtTb2hLPqtatVOW364/EKFq0/PSdnZVE9V2Zq+pbX7dj3nCS4pWnYf40ELH8wuDm0Tc4jQ70v4LgAcdy3JGTnWUGiCsY+0Z8kNzRkm3FJid592FL7ryzfvIzB9bjg8U2JqlyCVAyUYEnKv4lDAgMBAAE=\n-----END PUBLIC KEY-----",
// other parameters
"mode" : "ECB",
"padding" : "PKCS1",
"digest" : "SHA256"
},
"seed" : "hulk",
"fingerprint" : "jIPGWpWSbR/DQH6ol3t9DSFkYroVHQDvtbJErmFztMUP2DgRrRSNWuoKY5Y26qL38wfXJQXjYiWqNWKQmQe/gK8M8NkU7lRwm+2nh9wSBYV6Q4WXsCboKbnM0+HVn9Vdfp21hMMGrxTX1pBPRbi0567ZjNQC8ffdW2WvQSoec2I="
}
```
(All data encode with **BASE64** algorithm as default, excepts the **address**)
%prep
%autosetup -n mkm-0.12.6
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-mkm -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Thu May 18 2023 Python_Bot - 0.12.6-1
- Package Spec generated