I'm trying to create a minimum reproducible example, while doing so, i came across this error. How can i solve this?
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "<string>", line 10, in verified
TypeError: can only concatenate tuple (not "list") to tuple
import json
# Python3 program to convert a
# list into a tuple
def convert(list):
return tuple(list)
def verified(k_signer, sha256, d_signer, addr_from, seed, data, signature):
hash = (
k_signer
tuple(sha256.encode())
d_signer
tuple()
tuple()
tuple()
)
return hash
data = {'k_signer': [165, 118, 206, 164, 254, 84, 98, 136, 122, 95, 83, 186, 232, 134, 155, 198, 186, 72, 221, 207, 167, 67, 45, 62, 118, 121, 122, 42, 166, 42, 185, 149, 91, 39, 77, 188, 42, 215, 132, 148, 170, 99, 114, 144, 66, 93, 177, 127, 214, 55, 57, 230, 214, 246, 241, 122, 201, 13, 225, 173, 22, 195, 144, 54, 20, 193, 213, 187, 228, 24, 48, 239, 216, 157, 193, 255, 45, 103, 223, 33, 105, 92, 176, 197, 128, 158, 103, 130, 190, 139, 184, 224, 145, 150, 191, 81, 35, 135, 90, 182, 56, 203, 195, 183, 50, 188, 67, 49, 211, 170, 165, 70, 219, 215, 216, 160, 236, 89, 237, 193, 45, 71, 239, 153, 74, 229, 36, 101, 222, 222, 188, 168, 58, 99, 166, 37, 164, 63, 117, 54, 139, 205, 176, 154, 151, 130, 182, 87, 15, 116, 46, 165, 202, 95, 70, 204, 108, 152, 123, 28, 241, 120, 50, 249, 243, 45, 246, 248, 165, 107, 33, 198, 204, 178, 86, 169, 237, 248, 9, 175, 199, 136, 171, 161, 117, 229, 130, 238, 145, 143, 159, 103, 43, 205, 153, 61, 129, 65, 231, 41, 115, 89, 162, 13, 103, 95, 85, 147, 245, 152, 9, 99, 110, 61, 130, 210, 225, 188, 68, 224, 6, 173, 6, 177, 250, 82, 221, 12, 79, 5, 138, 218, 242, 239, 162, 99, 95, 249, 178, 163, 88, 37, 209, 141, 249, 163, 164, 231, 13, 30, 53, 207, 82, 163, 138, 11, 201, 187, 169, 117, 98, 174, 197, 131, 15, 206, 47, 211, 117, 219, 130, 92, 199, 147, 58, 22, 91, 55, 30, 160, 206, 178, 109, 61, 3, 124, 238, 242, 167, 67, 100, 224, 173, 96, 101, 97, 188, 222, 101, 47, 15, 123, 193, 232, 247, 235, 134, 171, 255, 180, 94, 234, 97, 193, 108, 28, 231, 164, 95, 232, 131, 181, 104, 11, 213, 222, 184, 175, 128, 157, 140, 148, 214, 43, 40, 135, 51, 197, 86, 123, 238, 85, 170, 51, 28, 133, 227, 124, 233, 7, 85, 99, 158, 203, 90, 160, 159, 105, 13, 164, 150, 126, 170, 155, 187, 104, 138, 173, 56, 46, 8, 82, 120, 170, 43, 62, 228, 146, 151, 26, 231, 42, 5, 130, 159, 37, 9, 70, 27, 14, 74, 17, 102, 83, 126, 243, 187, 131, 99, 114, 158, 239, 222, 175, 21, 215, 177, 13, 191, 151, 246, 229, 51, 112, 110, 42, 25, 122, 13, 96, 98, 81, 252, 122, 45, 165, 4, 108, 40, 101, 9, 75, 80, 97, 150, 218, 195, 175, 9, 133, 80, 131, 75, 244, 210, 232, 194, 227, 232, 22, 192, 40, 229, 208, 116, 121, 118, 164, 136, 115, 41, 97, 239, 7, 111, 193, 141, 228, 114, 22, 126, 192, 120, 130, 26, 110, 120, 183, 159, 149, 50, 3, 42, 15, 214, 160, 144, 193, 225, 243, 34, 35, 247, 249, 143, 24, 200, 240, 157, 7, 195, 35, 61, 233, 190, 163, 64, 188, 138, 89, 15, 102, 20, 11, 221, 158, 63, 61, 59, 153, 226, 58, 26, 131, 254, 138, 255, 84, 72, 32, 121, 123, 115, 69, 109, 96, 182, 171, 190, 154, 181, 131, 42, 177, 175, 26, 249, 112, 247, 126, 45, 231, 22, 241, 160, 12, 244, 104, 119, 149, 89, 156, 217, 65, 218, 95, 38, 190, 98, 95, 204, 149, 200, 121, 229, 195, 16, 213, 204, 4, 222, 187, 143, 171, 26, 56, 160, 16, 106, 166, 216, 91, 35, 178, 77, 115, 44, 143, 147, 130, 69, 209, 80, 133, 243, 23, 190, 100, 169, 245, 58, 58, 137, 187, 203, 74, 148, 112, 146, 82, 177, 210, 230, 253, 236, 144, 130, 15, 57, 45, 74, 110, 3, 167, 39, 227, 53, 91, 69, 252, 87, 195, 237, 239, 218, 45, 148, 237, 235, 150, 82, 99, 87, 11, 175, 136, 110, 220, 228, 15, 109, 76, 140, 59, 172, 122, 159, 78, 69, 38, 156, 239, 241, 130, 77, 115, 253, 203, 170, 103, 174, 163, 73, 121, 214, 115, 17, 119, 233, 244, 133, 38, 133, 106, 87, 144, 164, 64, 181, 74, 141, 82, 55, 78, 80, 132, 180, 225, 63, 213, 133, 219, 253, 142, 19, 210, 25, 232, 252, 36, 42, 176, 105, 27, 231, 72, 85, 80, 173, 229, 85, 90, 96, 102, 143, 152, 165, 13, 40, 0, 88, 100, 190, 180, 71, 184, 54, 60, 4, 253, 6, 97, 147, 196, 174, 239, 255, 19, 140, 234, 180, 7, 243, 80, 251, 57, 115, 103, 128, 231, 131, 196, 174, 116, 166, 105, 56, 148, 52, 29, 98, 116, 203, 23, 65, 66, 203, 71, 96, 233, 209, 170, 181, 36, 17, 86, 198, 174, 178, 176, 19, 47, 158, 5, 38, 249, 233, 63, 126, 67, 205, 131, 15, 189, 103, 153, 161, 153, 47, 19, 126, 197, 177, 129, 190, 105, 18, 22, 188, 194, 236, 170, 80, 28, 178, 24, 184, 54, 182, 202, 210, 239, 37, 41, 11, 204, 226, 214, 18, 140, 184, 230, 184, 42, 62, 99, 248, 126, 8, 237, 150, 79, 39, 69, 96, 87, 154, 3, 175, 193, 222, 212, 122, 173, 74, 88, 49, 92, 236, 186, 22, 114, 64, 41, 225, 20, 98, 34, 223, 29, 244, 71, 59, 23, 102, 46, 137, 14, 32, 54, 63, 190, 215, 16, 181, 112, 131, 146, 87, 142, 80, 234, 152, 36, 41, 175, 213, 244, 120, 186, 8, 159, 121, 93, 58, 82, 11, 112, 180, 44, 27, 158, 138, 231, 87, 190, 81, 174, 149, 171, 127, 119, 30, 244, 248, 155, 88, 117, 114, 26, 182, 103, 182, 142, 169, 30, 51, 70, 214, 63, 60, 152, 110, 14, 110, 148, 195, 107, 93, 12, 135, 35, 222, 187, 60, 117, 90, 51, 227, 127, 109, 24, 23, 223, 135, 98, 3, 119, 138, 16, 215, 134, 89, 243, 126, 218, 144, 52, 36, 59, 251, 243, 77, 118, 231, 147, 200, 212, 163, 242, 134, 78, 127, 252, 173, 98, 78, 151, 21, 106, 185, 139, 182, 228, 210, 79, 62, 63, 120, 15, 34, 189, 190, 164, 106, 133, 84, 156, 246, 128, 13, 94, 119, 182, 48, 251, 1, 170, 204, 193, 250, 114, 196, 50, 25, 5, 170, 167, 70, 128, 37, 168, 128, 200, 112, 104, 134, 182, 126, 202, 214, 170, 131, 198, 95, 237, 138, 205, 108, 135, 206, 102, 128, 94, 75, 209, 130, 175], 'd_pk': '81c0a09692ad852649aeca550e0c8a280814b1f2ee5b9cdba7fad5399e050c94', 'd_signer': [92, 179, 203, 137, 168, 215, 194, 231, 231, 220, 175, 55, 104, 195, 181, 202, 168, 124, 36, 109, 96, 52, 119, 111, 123, 228, 68, 52, 181, 176, 146, 52, 110, 192, 12, 72, 140, 192, 53, 100, 9, 182, 78, 181, 147, 164, 213, 10, 151, 175, 65, 17, 110, 223, 245, 47, 20, 208, 48, 41, 30, 236, 111, 168, 188, 193, 28, 201, 123, 106, 228, 90, 176, 80, 228, 237, 209, 104, 204, 165, 146, 66, 84, 137, 250, 123, 1, 169, 48, 28, 33, 131, 220, 15, 248, 189, 248, 196, 210, 54, 70, 84, 201, 197, 4, 169, 187, 74, 122, 147, 205, 245, 111, 164, 212, 30, 7, 134, 117, 220, 58, 85, 201, 124, 76, 119, 171, 16, 128, 75, 95, 142, 33, 112, 7, 235, 237, 106, 176, 42, 79, 101, 233, 123, 218, 40, 105, 40, 131, 178, 105, 26, 164, 83, 217, 72, 110, 192, 245, 134, 156, 200, 121, 190, 53, 159, 136, 149, 20, 92, 59, 158, 40, 180, 6, 85, 38, 37, 93, 140, 11, 230, 95, 178, 209, 159, 73, 21, 62, 164, 247, 235, 114, 164, 239, 84, 185, 99, 134, 105, 190, 168, 189, 167, 27, 238, 210, 2, 112, 69, 54, 80, 247, 122, 86, 253, 131, 10, 159, 124, 219, 234, 81, 177, 64, 99, 143, 18, 94, 3, 89, 126, 215, 254, 57, 136, 35, 251, 152, 4, 75, 83, 7, 14, 173, 250, 86, 240, 132, 155, 171, 59, 157, 144, 235, 150, 58, 239, 151, 106, 248, 62, 217, 115, 177, 243, 37, 62, 9, 112, 90, 140, 185, 240, 145, 164, 215, 124, 134, 196, 57, 138, 244, 108, 145, 11, 134, 234, 74, 14, 83, 168, 222, 161, 94, 196, 27, 62, 111, 11, 245, 13, 223, 217, 47, 99, 120, 59, 28, 42, 108, 190, 217, 153, 150, 225, 33, 129, 182, 150, 222, 184, 9, 211, 250, 40, 251, 26, 87, 30, 105, 113, 145, 86, 251, 186, 2, 48, 64, 78, 226, 97, 29, 180, 111, 247, 49, 19, 172, 160, 115, 128, 187, 240, 111, 243, 248, 11, 153, 91, 245, 24, 58, 252, 112, 187, 27, 121, 31, 167, 186, 76, 120, 233, 82, 227, 216, 104, 215, 29, 12, 12, 64, 186, 167, 219, 232, 4, 42, 243, 80, 133, 189, 137, 153, 195, 94, 197, 53, 121, 178, 185, 130, 75, 22, 139, 144, 149, 183, 245, 40, 120, 155, 165, 174, 7, 167, 181, 162, 119, 237, 197, 38, 65, 9, 118, 213, 181, 211, 221, 15, 59, 203, 170, 144, 112, 198, 212, 142, 173, 131, 227, 47, 242, 125, 175, 250, 168, 202, 212, 196, 247, 16, 252, 32, 130, 19, 183, 197, 152, 227, 141, 52, 55, 200, 15, 20, 97, 204, 65, 93, 10, 120, 31, 15, 181, 5, 206, 152, 136, 15, 123, 62, 56, 41, 77, 186, 12, 130, 52, 214, 202, 19, 248, 159, 45, 60, 27, 161, 44, 27, 187, 86, 213, 105, 23, 80, 153, 214, 245, 35, 66, 210, 98, 56, 245, 117, 156, 78, 78, 47, 35, 204, 105, 234, 210, 165, 101, 148, 112, 48, 233, 236, 73, 113, 182, 166, 187, 148, 32, 131, 68, 76, 85, 241, 41, 160, 23, 156, 84, 103, 66, 137, 3, 154, 30, 167, 192, 237, 211, 122, 65, 195, 65, 212, 121, 49, 235, 68, 201, 11, 13, 93, 149, 14, 221, 51, 31, 108, 134, 83, 93, 155, 61, 32, 57, 240, 180, 161, 235, 211, 66, 126, 100, 95, 131, 109, 198, 54, 37, 62, 137, 50, 82, 153, 255, 213, 2, 181, 72, 145, 248, 127, 150, 33, 22, 116, 128, 52, 102, 39, 17, 42, 83, 116, 80, 245, 220, 80, 113, 226, 20, 196, 84, 91, 215, 172, 92, 88, 128, 146, 220, 102, 243, 125, 13, 216, 215, 253, 102, 224, 212, 225, 126, 145, 135, 188, 163, 4, 71, 218, 141, 77, 112, 100, 235, 236, 104, 27, 214, 216, 97, 49, 245, 236, 45, 136, 5, 96, 17, 171, 70, 254, 205, 252, 85, 26, 11, 3, 50, 153, 5, 6, 18, 38, 87, 251, 25, 111, 236, 216, 28, 95, 163, 218, 170, 16, 59, 140, 96, 220, 87, 191, 133, 47, 127, 100, 184, 241, 40, 167, 140, 115, 193, 17, 28, 209, 208, 43, 4, 50, 117, 181, 65, 236, 131, 71, 163, 119, 101, 67, 174, 160, 220, 231, 177, 245, 80, 115, 201, 34, 195, 158, 24, 42, 103, 198, 136, 152, 93, 190, 61, 169, 105, 188, 109, 185, 90, 14, 126, 238, 33, 234, 17, 151, 148, 91, 178, 93, 198, 188, 178, 26, 218, 78, 236, 16, 156, 146, 19, 227, 18, 103, 254, 182, 51, 186, 96, 223, 105, 129, 228, 81, 12, 150, 92, 88, 146, 171, 73, 243, 9, 126, 195, 1, 57, 60, 113, 204, 21, 87, 160, 166, 162, 118, 26, 112, 45, 153, 59, 41, 84, 247, 190, 29, 26, 26, 45, 99, 202, 65, 224, 37, 142, 37, 192, 116, 255, 129, 13, 246, 71, 172, 40, 138, 140, 44, 255, 209, 188, 175, 60, 230, 215, 86, 229, 217, 141, 115, 38, 154, 5, 123, 32, 247, 173, 166, 149, 70, 91, 68, 172, 168, 92, 147, 170, 5, 95, 75, 188, 101, 48, 160, 145, 225, 66, 192, 56, 138, 208, 121, 222, 23, 164, 228, 78, 3, 182, 172, 94, 107, 237, 114, 208, 233, 191, 209, 69, 58, 38, 255, 207, 226, 212, 124, 62, 186, 3, 198, 55, 147, 17, 52, 84, 78, 137, 172, 200, 140, 70, 8, 187, 55, 235, 129, 247, 186, 96, 194, 225, 9, 94, 38, 19, 119, 170, 247, 243, 43, 54, 112, 54, 172, 67, 29, 201, 17, 141, 143, 37, 105, 62, 82, 244, 131, 148, 106, 99, 147, 46, 0, 7, 242, 47, 231, 201, 105, 127, 111, 140, 58, 228, 216, 128, 236, 33, 42, 245, 128, 88, 111, 95, 200, 56, 37, 84, 184, 80, 179, 102, 226, 39, 179, 112, 188, 90, 137, 111, 158, 162, 116, 63, 169, 250, 126, 29, 22, 41, 31, 148, 193, 99, 64, 67, 216, 160, 73, 154, 184, 129, 246, 44, 102, 21, 168, 126, 145, 169, 203, 232, 6, 59, 65, 125, 180, 122, 28, 33, 91, 66, 68, 11, 246, 74, 118, 52, 229, 200, 28, 209, 215, 255, 68, 122, 40, 146, 124, 181, 245, 25, 179, 139, 95, 42, 74, 228, 207, 206, 2, 239, 156, 136, 73, 221, 73, 248, 94, 184, 75, 148, 126, 25, 71, 22, 237, 14, 53, 132, 145, 216, 64, 172, 212, 153, 178, 182, 93, 71, 113, 109, 64, 41, 146, 190, 22, 198, 238, 171, 72, 155, 6, 182, 205, 234, 157, 74, 43, 188, 187, 28, 94, 0, 138, 133, 238, 30, 216, 154, 160, 31, 87, 137, 58, 217, 221, 186, 154, 138, 244, 50, 30, 253, 220, 34, 175, 0, 139, 55, 26, 103, 35, 136, 210, 180, 7, 223, 221, 201, 212, 190, 39, 128, 63, 46, 210, 156, 149, 19, 41, 41, 77, 147, 26, 253, 40, 253, 134, 125, 115, 89, 117, 156, 169, 47, 154, 227, 178, 155, 20, 40, 79, 82, 164, 103, 55, 107, 251, 8, 95, 197, 237, 81, 14, 18, 16, 62, 14, 48, 28, 206, 137, 27, 247, 69, 214, 38, 201, 128, 128, 105, 197, 72, 135, 246, 249, 24, 244, 244, 6, 73, 146, 2, 186, 54, 50, 143, 77, 118, 185, 187, 252, 195, 32, 11, 40, 224, 212, 41, 26, 238, 23, 81, 67, 81, 200, 3, 15, 19, 45, 129, 22, 17, 189, 107, 111, 239, 235, 57, 58, 145, 230, 37, 212, 75, 189, 44, 191, 123, 9, 250, 137, 224, 186, 84, 145, 158, 236, 11, 83, 142, 103, 92, 71, 98, 214, 103, 184, 10, 36, 208, 143, 74, 186, 201, 158, 166, 67, 144, 15, 183, 228, 12, 193, 220, 199, 141, 64, 234, 145, 94, 212, 110, 15, 14, 92, 84, 57, 50, 164, 252, 198, 205, 233, 18, 175, 239, 161, 196, 89, 188, 165, 189, 16, 162, 108, 6, 187, 140, 197, 165, 202, 107, 193, 54, 44, 163, 10, 241, 218, 30, 197, 37, 1, 189, 180, 133, 214, 32, 245, 16, 46, 49, 239, 156, 56, 151, 36, 115, 170, 222, 96, 135, 165, 9, 191, 10, 207, 128, 219, 170, 102, 85, 2, 8, 59, 237, 132, 35, 94, 187, 139, 136, 243, 50, 103, 43, 140, 167, 51, 70, 252, 200, 198, 120, 13, 212, 85, 35, 170, 135, 196, 38, 190, 172, 190, 136, 12, 50, 67, 209, 125, 228, 189, 164, 247, 38, 69, 79, 122, 149, 172, 221, 41, 25, 254, 126, 156, 38, 201, 56, 239, 158], 'sig': True, 'addr': [], 'seed': [], 'data': []}
serialized_data = json.dumps(data)
data = json.loads(serialized_data)
is_verified = verified(convert(data['k_signer']), data['d_pk'], data['d_signer'], data['sig'], data['addr'], data['seed'], data['data'])
print(is_verified)
CodePudding user response:
You forgot to call the conversion function for some parameter in your function.
I tested and corrected your code, call it this way:
is_verified = verified(
convert(data['k_signer']),
data['d_pk'],
convert(data['d_signer']),
data['sig'],
convert(data['addr']),
convert(data['seed']),
convert(data['data'])
)
CodePudding user response:
You might also convert(data['d_signer']) as below:
is_verified = verified(convert(data['k_signer']), data['d_pk'], convert(data['d_signer']), data['sig'], data['addr'], data['seed'], data['data'])